internal/graphics: refactoring

This commit is contained in:
Hajime Hoshi 2022-04-05 11:12:25 +09:00
parent c6e5582c56
commit 32de5ec2d0

View File

@ -101,18 +101,20 @@ func imageSrc%[1]dAt(pos vec2) vec4 {
}
`, i, pos)
}
shaderSuffix += `
var __projectionMatrix mat4
func __vertex(position vec2, texCoord vec2, color vec4) (vec4, vec2, vec4) {
return __projectionMatrix * vec4(position, 0, 1), texCoord, color
}
`
}
func CompileShader(src []byte) (*shaderir.Program, error) {
var buf bytes.Buffer
buf.Write(src)
buf.WriteString(shaderSuffix)
buf.WriteString(`var __projectionMatrix mat4
func __vertex(position vec2, texCoord vec2, color vec4) (vec4, vec2, vec4) {
return __projectionMatrix * vec4(position, 0, 1), texCoord, color
}
`)
fs := token.NewFileSet()
f, err := parser.ParseFile(fs, "", buf.Bytes(), parser.AllErrors)