mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/shader: bug fix: wrong type deduction at (scalar)*(matrix)
Updates #2037
This commit is contained in:
parent
6bd3c81e27
commit
aef00a5235
@ -232,7 +232,7 @@ func (cs *compileState) parseExpr(block *block, expr ast.Expr, markLocalVariable
|
|||||||
cs.addError(e.Pos(), fmt.Sprintf("types don't match: %s %s %s", lhst.String(), e.Op, rhst.String()))
|
cs.addError(e.Pos(), fmt.Sprintf("types don't match: %s %s %s", lhst.String(), e.Op, rhst.String()))
|
||||||
return nil, nil, nil, false
|
return nil, nil, nil, false
|
||||||
}
|
}
|
||||||
t = lhst
|
t = rhst
|
||||||
default:
|
default:
|
||||||
cs.addError(e.Pos(), fmt.Sprintf("types don't match: %s %s %s", lhst.String(), e.Op, rhst.String()))
|
cs.addError(e.Pos(), fmt.Sprintf("types don't match: %s %s %s", lhst.String(), e.Op, rhst.String()))
|
||||||
return nil, nil, nil, false
|
return nil, nil, nil, false
|
||||||
|
@ -734,9 +734,10 @@ func TestShaderUniformMatrix2(t *testing.T) {
|
|||||||
s, err := ebiten.NewShader([]byte(`package main
|
s, err := ebiten.NewShader([]byte(`package main
|
||||||
|
|
||||||
var Mat2 mat2
|
var Mat2 mat2
|
||||||
|
var F float
|
||||||
|
|
||||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||||
return vec4(Mat2 * vec2(1), 1, 1)
|
return vec4(F * Mat2 * vec2(1), 1, 1)
|
||||||
}
|
}
|
||||||
`))
|
`))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -749,13 +750,14 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
1.0 / 256.0, 2.0 / 256.0,
|
1.0 / 256.0, 2.0 / 256.0,
|
||||||
3.0 / 256.0, 4.0 / 256.0,
|
3.0 / 256.0, 4.0 / 256.0,
|
||||||
},
|
},
|
||||||
|
"F": float32(2),
|
||||||
}
|
}
|
||||||
dst.DrawRectShader(w, h, s, op)
|
dst.DrawRectShader(w, h, s, op)
|
||||||
|
|
||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := dst.At(i, j).(color.RGBA)
|
got := dst.At(i, j).(color.RGBA)
|
||||||
want := color.RGBA{4, 6, 0xff, 0xff}
|
want := color.RGBA{8, 12, 0xff, 0xff}
|
||||||
if !sameColors(got, want, 2) {
|
if !sameColors(got, want, 2) {
|
||||||
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user