From de1ef0bec88e627a9684263451250025aa1a6867 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 16 Nov 2024 15:29:52 +0900 Subject: [PATCH] internal/builtinshader: refactoring --- internal/builtinshader/gen.go | 23 ++++++++++++++--------- internal/builtinshader/shader.go | 9 --------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/internal/builtinshader/gen.go b/internal/builtinshader/gen.go index 5130ec58c748..993f9197ff10 100644 --- a/internal/builtinshader/gen.go +++ b/internal/builtinshader/gen.go @@ -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 + } + } } } diff --git a/internal/builtinshader/shader.go b/internal/builtinshader/shader.go index 0a9eecbdc140..5be57319d957 100644 --- a/internal/builtinshader/shader.go +++ b/internal/builtinshader/shader.go @@ -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 -}