mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
shaderir: Add func params
This commit is contained in:
parent
919fc29016
commit
3d7c102472
@ -80,8 +80,27 @@ func (p *Program) glslVarDecl(t *Type, varname string) string {
|
||||
}
|
||||
|
||||
func (p *Program) glslFunc(f *Func) []string {
|
||||
var args []string
|
||||
var idx int
|
||||
for _, t := range f.InParams {
|
||||
args = append(args, "in "+p.glslVarDecl(&t, fmt.Sprintf("l%d", idx)))
|
||||
idx++
|
||||
}
|
||||
for _, t := range f.InOutParams {
|
||||
args = append(args, "inout "+p.glslVarDecl(&t, fmt.Sprintf("l%d", idx)))
|
||||
idx++
|
||||
}
|
||||
for _, t := range f.OutParams {
|
||||
args = append(args, "out "+p.glslVarDecl(&t, fmt.Sprintf("l%d", idx)))
|
||||
idx++
|
||||
}
|
||||
argsstr := "void"
|
||||
if len(args) > 0 {
|
||||
argsstr = strings.Join(args, ", ")
|
||||
}
|
||||
|
||||
return []string{
|
||||
fmt.Sprintf(`void %s(void) {`, f.Name),
|
||||
fmt.Sprintf(`void %s(%s) {`, f.Name, argsstr),
|
||||
`}`,
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ attribute vec2 A0;
|
||||
varying vec3 V0;`,
|
||||
},
|
||||
{
|
||||
Name: "Function",
|
||||
Name: "Func",
|
||||
Program: Program{
|
||||
Funcs: []Func{
|
||||
{
|
||||
@ -99,6 +99,29 @@ varying vec3 V0;`,
|
||||
},
|
||||
},
|
||||
Glsl: `void F0(void) {
|
||||
}`,
|
||||
},
|
||||
{
|
||||
Name: "FuncParams",
|
||||
Program: Program{
|
||||
Funcs: []Func{
|
||||
{
|
||||
Name: "F0",
|
||||
InParams: []Type{
|
||||
{Main: Float},
|
||||
{Main: Vec2},
|
||||
{Main: Vec4},
|
||||
},
|
||||
InOutParams: []Type{
|
||||
{Main: Mat2},
|
||||
},
|
||||
OutParams: []Type{
|
||||
{Main: Mat4},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Glsl: `void F0(in float l0, in vec2 l1, in vec4 l2, inout mat2 l3, out mat4 l4) {
|
||||
}`,
|
||||
},
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ type Variable struct {
|
||||
type Func struct {
|
||||
Name string
|
||||
InParams []Type
|
||||
InOutParams []Type
|
||||
OutParams []Type
|
||||
Block Block
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user