diff --git a/internal/graphics/opengl/context.go b/internal/graphics/opengl/context.go index 4fefa5ed4..f32a28f29 100644 --- a/internal/graphics/opengl/context.go +++ b/internal/graphics/opengl/context.go @@ -39,9 +39,11 @@ type Context struct { context } -func (c *Context) bindFramebuffer(f Framebuffer) { +func (c *Context) bindFramebuffer(f Framebuffer) bool { if c.lastFramebuffer != f { c.bindFramebufferImpl(f) c.lastFramebuffer = f + return true } + return false } diff --git a/internal/graphics/opengl/context_desktop.go b/internal/graphics/opengl/context_desktop.go index 30316149a..b87da67f6 100644 --- a/internal/graphics/opengl/context_desktop.go +++ b/internal/graphics/opengl/context_desktop.go @@ -228,8 +228,9 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) { func (c *Context) SetViewport(f Framebuffer, width, height int) error { return c.RunOnContextThread(func() error { - c.bindFramebuffer(f) - gl.Viewport(0, 0, int32(width), int32(height)) + if c.bindFramebuffer(f) { + gl.Viewport(0, 0, int32(width), int32(height)) + } return nil }) } diff --git a/internal/graphics/opengl/context_js.go b/internal/graphics/opengl/context_js.go index 0da88f3da..348720fd4 100644 --- a/internal/graphics/opengl/context_js.go +++ b/internal/graphics/opengl/context_js.go @@ -205,9 +205,10 @@ func (c *Context) NewFramebuffer(t Texture) (Framebuffer, error) { } func (c *Context) SetViewport(f Framebuffer, width, height int) error { - c.bindFramebuffer(f) - gl := c.gl - gl.Viewport(0, 0, width, height) + if c.bindFramebuffer(f) { + gl := c.gl + gl.Viewport(0, 0, width, height) + } return nil } diff --git a/internal/graphics/opengl/context_mobile.go b/internal/graphics/opengl/context_mobile.go index 1a1b0b5bd..04f9ba39a 100644 --- a/internal/graphics/opengl/context_mobile.go +++ b/internal/graphics/opengl/context_mobile.go @@ -182,9 +182,10 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) { } func (c *Context) SetViewport(f Framebuffer, width, height int) error { - gl := c.gl - c.bindFramebuffer(f) - gl.Viewport(0, 0, width, height) + if c.bindFramebuffer(f) { + gl := c.gl + gl.Viewport(0, 0, width, height) + } return nil }