From da14685fb03e3dcbff72ed6072f1b81bf9a41777 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 17 Jan 2015 00:56:29 +0900 Subject: [PATCH] Bug fix: Structs containing js.Object can't be compared (for now) --- internal/graphics/internal/shader/program.go | 2 +- internal/opengl/context.go | 10 ++++++++-- internal/opengl/context_js.go | 8 +++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/graphics/internal/shader/program.go b/internal/graphics/internal/shader/program.go index 6018f62de..1533c44c8 100644 --- a/internal/graphics/internal/shader/program.go +++ b/internal/graphics/internal/shader/program.go @@ -67,7 +67,7 @@ func initialize(c *opengl.Context) error { var lastProgram opengl.Program func useProgramColorMatrix(c *opengl.Context, projectionMatrix []float32, geo Matrix, color Matrix) opengl.Program { - if lastProgram != programColorMatrix { + if !lastProgram.Equals(programColorMatrix) { c.UseProgram(programColorMatrix) lastProgram = programColorMatrix } diff --git a/internal/opengl/context.go b/internal/opengl/context.go index 9e593d28f..4de5f08ab 100644 --- a/internal/opengl/context.go +++ b/internal/opengl/context.go @@ -26,8 +26,14 @@ type Texture int type Framebuffer int type Shader int type Program int -type UniformLocation int -type AttribLocation int + +// TODO: Remove this after the GopherJS bug was fixed (#159) +func (p Program) Equals(other Program) bool { + return p == other +} + +type UniformLocation gl.UniformLocation +type AttribLocation gl.AttribLocation type context struct{} diff --git a/internal/opengl/context_js.go b/internal/opengl/context_js.go index 3ffc15cdd..7690205df 100644 --- a/internal/opengl/context_js.go +++ b/internal/opengl/context_js.go @@ -39,6 +39,11 @@ type Program struct { js.Object } +// TODO: Remove this after the GopherJS bug was fixed (#159) +func (p Program) Equals(other Program) bool { + return p.Object == other.Object +} + type UniformLocation struct { js.Object } @@ -141,7 +146,8 @@ var lastFramebuffer Framebuffer func (c *Context) SetViewport(f Framebuffer, width, height int) error { gl := c.gl - if lastFramebuffer != f { + // TODO: Fix this after the GopherJS bug was fixed (#159) + if lastFramebuffer.Object != f.Object { gl.Flush() lastFramebuffer = f }