shaderir: Fix integer literals

This commit is contained in:
Hajime Hoshi 2020-06-02 21:45:33 +09:00
parent 909ba638a3
commit 3118657fff
2 changed files with 4 additions and 4 deletions

View File

@ -55,7 +55,7 @@ func Foo(foo vec2) vec4 {
return vec4(foo, 0, 1)
}`,
VS: `void F0(in vec2 l0, out vec4 l1) {
l1 = vec4(l0, 0, 1);
l1 = vec4(l0, 0.0, 1.0);
return;
}`,
},
@ -124,10 +124,9 @@ func Foo(foo vec2) vec4 {
r := vec4(foo, 0, 1)
return r
}`,
// TODO: number literals must be floats.
VS: `void F0(in vec2 l0, out vec4 l1) {
vec4 l2 = vec4(0.0);
l2 = vec4(l0, 0, 1);
l2 = vec4(l0, 0.0, 1.0);
l1 = l2;
return;
}`,

View File

@ -234,7 +234,8 @@ func (p *Program) glslBlock(b *Block, level int, localVarIndex int) []string {
glslExpr = func(e *Expr) string {
switch e.Type {
case IntExpr:
return fmt.Sprintf("%d", e.Int)
// TODO: Cast to int if the context requries integers.
return fmt.Sprintf("%d.0", e.Int)
case FloatExpr:
return fmt.Sprintf("%.9e", e.Float)
case UniformVariable: