mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 10:42:42 +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
|
||||
glslExpr = func(e *Expr) string {
|
||||
switch e.Type {
|
||||
case Numeric:
|
||||
return fmt.Sprintf("%.9e", e.Num)
|
||||
case IntExpr:
|
||||
return fmt.Sprintf("%d", e.Int)
|
||||
case FloatExpr:
|
||||
return fmt.Sprintf("%.9e", e.Float)
|
||||
case VarName:
|
||||
switch e.Variable.Type {
|
||||
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{
|
||||
Type: Numeric,
|
||||
Num: value,
|
||||
Type: FloatExpr,
|
||||
Float: value,
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,7 +291,7 @@ varying vec3 V0;`,
|
||||
binaryExpr(
|
||||
Eq,
|
||||
varNameExpr(Local, 0),
|
||||
numericExpr(0),
|
||||
floatExpr(0),
|
||||
),
|
||||
block(
|
||||
nil,
|
||||
|
@ -66,7 +66,8 @@ type Expr struct {
|
||||
Type ExprType
|
||||
Exprs []Expr
|
||||
Variable Variable
|
||||
Num float64
|
||||
Int int32
|
||||
Float float32
|
||||
Ident string
|
||||
Op Op
|
||||
}
|
||||
@ -74,7 +75,8 @@ type Expr struct {
|
||||
type ExprType int
|
||||
|
||||
const (
|
||||
Numeric ExprType = iota
|
||||
IntExpr ExprType = iota
|
||||
FloatExpr
|
||||
VarName
|
||||
Ident
|
||||
Unary
|
||||
|
Loading…
Reference in New Issue
Block a user