diff --git a/internal/opengl/context.go b/internal/opengl/context.go index d69ecd159..8c96ce4d4 100644 --- a/internal/opengl/context.go +++ b/internal/opengl/context.go @@ -54,7 +54,7 @@ func GetContext() *Context { } func (c *Context) BindTexture(t Texture) error { - if c.lastTexture == t { + if c.lastTexture.equals(t) { return nil } if err := c.bindTextureImpl(t); err != nil { @@ -65,7 +65,7 @@ func (c *Context) BindTexture(t Texture) error { } func (c *Context) bindFramebuffer(f Framebuffer) error { - if c.lastFramebuffer == f { + if c.lastFramebuffer.equals(f) { return nil } if err := c.bindFramebufferImpl(f); err != nil { diff --git a/internal/opengl/context_desktop.go b/internal/opengl/context_desktop.go index 597e44ebf..246c07b7f 100644 --- a/internal/opengl/context_desktop.go +++ b/internal/opengl/context_desktop.go @@ -32,6 +32,14 @@ type Shader uint32 type Program uint32 type Buffer uint32 +func (t Texture) equals(other Texture) bool { + return t == other +} + +func (f Framebuffer) equals(other Framebuffer) bool { + return f == other +} + type uniformLocation int32 type attribLocation int32 diff --git a/internal/opengl/context_js.go b/internal/opengl/context_js.go index 07d8aaa4b..a27dfb427 100644 --- a/internal/opengl/context_js.go +++ b/internal/opengl/context_js.go @@ -24,6 +24,9 @@ import ( "github.com/gopherjs/webgl" ) +// Note that `type Texture *js.Object` doesn't work. +// There is no way to get the internal object in that case. + type Texture struct { *js.Object } @@ -44,6 +47,14 @@ type Buffer struct { *js.Object } +func (t Texture) equals(other Texture) bool { + return t.Object == other.Object +} + +func (f Framebuffer) equals(other Framebuffer) bool { + return f.Object == other.Object +} + type uniformLocation struct { *js.Object } diff --git a/internal/opengl/context_mobile.go b/internal/opengl/context_mobile.go index 81e75c689..7261cefeb 100644 --- a/internal/opengl/context_mobile.go +++ b/internal/opengl/context_mobile.go @@ -31,6 +31,14 @@ type Shader mgl.Shader type Program mgl.Program type Buffer mgl.Buffer +func (t Texture) equals(other Texture) bool { + return t == other +} + +func (f Framebuffer) equals(other Framebuffer) bool { + return f == other +} + type uniformLocation mgl.Uniform type attribLocation mgl.Attrib