Skip to content

Commit

Permalink
internal/builtinshader: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Nov 16, 2024
1 parent d021209 commit de1ef0b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
23 changes: 14 additions & 9 deletions internal/builtinshader/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,20 @@ func xmain() error {
return err
}

for _, s := range builtinshader.AppendShaderSources(nil) {
if _, err := w.WriteString("\n"); err != nil {
return err
}
if _, err := w.WriteString("//ebitengine:shader\n"); err != nil {
return err
}
if _, err := fmt.Fprintf(w, "const _ = %q\n", s); err != nil {
return err
for filter := builtinshader.Filter(0); filter < builtinshader.FilterCount; filter++ {
for address := builtinshader.Address(0); address < builtinshader.AddressCount; address++ {
for _, useColorM := range []bool{false, true} {
s := builtinshader.ShaderSource(filter, address, useColorM)
if _, err := w.WriteString("\n"); err != nil {
return err
}
if _, err := w.WriteString("//ebitengine:shader\n"); err != nil {
return err
}
if _, err := fmt.Fprintf(w, "const _ = %q\n", s); err != nil {
return err
}
}
}
}

Expand Down
9 changes: 0 additions & 9 deletions internal/builtinshader/shader.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,3 @@ func Fragment() vec4 {
return vec4(0)
}
`

func AppendShaderSources(sources [][]byte) [][]byte {
for filter := Filter(0); filter < FilterCount; filter++ {
for address := Address(0); address < AddressCount; address++ {
sources = append(sources, ShaderSource(filter, address, false), ShaderSource(filter, address, true))
}
}
return sources
}

0 comments on commit de1ef0b

Please sign in to comment.