mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 03:02:49 +01:00
shaderir: Allow integer literals
This commit is contained in:
parent
3cffe88334
commit
9f4985943c
@ -119,8 +119,10 @@ func (p *Program) glslBlock(b *Block, f *Func, level int, localVarIndex int) []s
|
|||||||
var glslExpr func(e *Expr) string
|
var glslExpr func(e *Expr) string
|
||||||
glslExpr = func(e *Expr) string {
|
glslExpr = func(e *Expr) string {
|
||||||
switch e.Type {
|
switch e.Type {
|
||||||
case Numeric:
|
case IntExpr:
|
||||||
return fmt.Sprintf("%.9e", e.Num)
|
return fmt.Sprintf("%d", e.Int)
|
||||||
|
case FloatExpr:
|
||||||
|
return fmt.Sprintf("%.9e", e.Float)
|
||||||
case VarName:
|
case VarName:
|
||||||
switch e.Variable.Type {
|
switch e.Variable.Type {
|
||||||
case Uniform:
|
case Uniform:
|
||||||
|
@ -59,10 +59,10 @@ func forStmt(init, end, delta int, block Block) Stmt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func numericExpr(value float64) Expr {
|
func floatExpr(value float32) Expr {
|
||||||
return Expr{
|
return Expr{
|
||||||
Type: Numeric,
|
Type: FloatExpr,
|
||||||
Num: value,
|
Float: value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ varying vec3 V0;`,
|
|||||||
binaryExpr(
|
binaryExpr(
|
||||||
Eq,
|
Eq,
|
||||||
varNameExpr(Local, 0),
|
varNameExpr(Local, 0),
|
||||||
numericExpr(0),
|
floatExpr(0),
|
||||||
),
|
),
|
||||||
block(
|
block(
|
||||||
nil,
|
nil,
|
||||||
|
@ -66,7 +66,8 @@ type Expr struct {
|
|||||||
Type ExprType
|
Type ExprType
|
||||||
Exprs []Expr
|
Exprs []Expr
|
||||||
Variable Variable
|
Variable Variable
|
||||||
Num float64
|
Int int32
|
||||||
|
Float float32
|
||||||
Ident string
|
Ident string
|
||||||
Op Op
|
Op Op
|
||||||
}
|
}
|
||||||
@ -74,7 +75,8 @@ type Expr struct {
|
|||||||
type ExprType int
|
type ExprType int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Numeric ExprType = iota
|
IntExpr ExprType = iota
|
||||||
|
FloatExpr
|
||||||
VarName
|
VarName
|
||||||
Ident
|
Ident
|
||||||
Unary
|
Unary
|
||||||
|
Loading…
Reference in New Issue
Block a user