diff --git a/gpu/gl/types.go b/gpu/gl/types.go index 291001fa..f986bbab 100644 --- a/gpu/gl/types.go +++ b/gpu/gl/types.go @@ -14,22 +14,14 @@ type ( Object struct{ V uint } ) -func (u Uniform) Valid() bool { +func (u Uniform) valid() bool { return u.V != -1 } -func (p Program) Valid() bool { +func (p Program) valid() bool { return p.V != 0 } -func (s Shader) Valid() bool { +func (s Shader) valid() bool { return s.V != 0 } - -func (t Texture) Valid() bool { - return t.V != 0 -} - -func (t Texture) Equal(t2 Texture) bool { - return t == t2 -} diff --git a/gpu/gl/types_js.go b/gpu/gl/types_js.go index 8f0419a8..16e3a713 100644 --- a/gpu/gl/types_js.go +++ b/gpu/gl/types_js.go @@ -16,22 +16,14 @@ type ( Object js.Value ) -func (p Program) Valid() bool { +func (p Program) valid() bool { return !js.Value(p).IsUndefined() && !js.Value(p).IsNull() } -func (s Shader) Valid() bool { +func (s Shader) valid() bool { return !js.Value(s).IsUndefined() && !js.Value(s).IsNull() } -func (u Uniform) Valid() bool { +func (u Uniform) valid() bool { return !js.Value(u).IsUndefined() && !js.Value(u).IsNull() } - -func (t Texture) Valid() bool { - return !js.Value(t).IsUndefined() && !js.Value(t).IsNull() -} - -func (t Texture) Equal(t2 Texture) bool { - return js.Value(t).Equal(js.Value(t2)) -} diff --git a/gpu/gl/util.go b/gpu/gl/util.go index 17e95980..7a7afa77 100644 --- a/gpu/gl/util.go +++ b/gpu/gl/util.go @@ -20,7 +20,7 @@ func CreateProgram(ctx Functions, vsSrc, fsSrc string, attribs []string) (Progra } defer ctx.DeleteShader(fs) prog := ctx.CreateProgram() - if !prog.Valid() { + if !prog.valid() { return Program{}, errors.New("glCreateProgram failed") } ctx.AttachShader(prog, vs) @@ -39,7 +39,7 @@ func CreateProgram(ctx Functions, vsSrc, fsSrc string, attribs []string) (Progra func GetUniformLocation(ctx Functions, prog Program, name string) Uniform { loc := ctx.GetUniformLocation(prog, name) - if !loc.Valid() { + if !loc.valid() { panic(fmt.Errorf("uniform %s not found", name)) } return loc @@ -47,7 +47,7 @@ func GetUniformLocation(ctx Functions, prog Program, name string) Uniform { func createShader(ctx Functions, typ Enum, src string) (Shader, error) { sh := ctx.CreateShader(typ) - if !sh.Valid() { + if !sh.valid() { return Shader{}, errors.New("glCreateShader failed") } ctx.ShaderSource(sh, src)