diff --git a/internal/opengl/context.go b/internal/opengl/context.go index abe2f5f49..95fccba5b 100644 --- a/internal/opengl/context.go +++ b/internal/opengl/context.go @@ -61,21 +61,16 @@ func (c *Context) BindTexture(t Texture) { c.lastTexture = t } -func (c *Context) bindFramebuffer(f Framebuffer) error { +func (c *Context) bindFramebuffer(f Framebuffer) { if c.lastFramebuffer.equals(f) { - return nil - } - if err := c.bindFramebufferImpl(f); err != nil { - return err + return } + c.bindFramebufferImpl(f) c.lastFramebuffer = f - return nil } func (c *Context) SetViewport(f Framebuffer, width, height int) error { - if err := c.bindFramebuffer(f); err != nil { - return err - } + c.bindFramebuffer(f) if c.lastViewportWidth != width || c.lastViewportHeight != height { if err := c.setViewportImpl(width, height); err != nil { return nil diff --git a/internal/opengl/context_desktop.go b/internal/opengl/context_desktop.go index 29cfa12b4..8815d8231 100644 --- a/internal/opengl/context_desktop.go +++ b/internal/opengl/context_desktop.go @@ -169,14 +169,11 @@ func (c *Context) NewTexture(width, height int, pixels []uint8, filter Filter) ( return texture, nil } -func (c *Context) bindFramebufferImpl(f Framebuffer) error { - if err := c.runOnContextThread(func() error { +func (c *Context) bindFramebufferImpl(f Framebuffer) { + _ = c.runOnContextThread(func() error { gl.BindFramebuffer(gl.FRAMEBUFFER, uint32(f)) return nil - }); err != nil { - return err - } - return nil + }) } func (c *Context) FramebufferPixels(f Framebuffer, width, height int) ([]uint8, error) { @@ -187,9 +184,7 @@ func (c *Context) FramebufferPixels(f Framebuffer, width, height int) ([]uint8, }); err != nil { return nil, err } - if err := c.bindFramebuffer(f); err != nil { - return nil, err - } + c.bindFramebuffer(f) if err := c.runOnContextThread(func() error { pixels = make([]uint8, 4*width*height) gl.ReadPixels(0, 0, int32(width), int32(height), gl.RGBA, gl.UNSIGNED_BYTE, gl.Ptr(pixels)) @@ -241,8 +236,8 @@ func (c *Context) TexSubImage2D(p []uint8, width, height int) { }) } -func (c *Context) BindScreenFramebuffer() error { - return c.bindFramebuffer(c.screenFramebuffer) +func (c *Context) BindScreenFramebuffer() { + c.bindFramebuffer(c.screenFramebuffer) } func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) { @@ -258,9 +253,7 @@ func (c *Context) NewFramebuffer(texture Texture) (Framebuffer, error) { }); err != nil { return 0, err } - if err := c.bindFramebuffer(Framebuffer(f)); err != nil { - return 0, err - } + c.bindFramebuffer(Framebuffer(f)) if err := c.runOnContextThread(func() error { gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, uint32(texture), 0) s := gl.CheckFramebufferStatus(gl.FRAMEBUFFER) diff --git a/internal/opengl/context_js.go b/internal/opengl/context_js.go index c64c180b0..764b657a5 100644 --- a/internal/opengl/context_js.go +++ b/internal/opengl/context_js.go @@ -192,10 +192,9 @@ func (c *Context) NewTexture(width, height int, pixels []uint8, filter Filter) ( return Texture{t}, nil } -func (c *Context) bindFramebufferImpl(f Framebuffer) error { +func (c *Context) bindFramebufferImpl(f Framebuffer) { gl := c.gl gl.BindFramebuffer(gl.FRAMEBUFFER, f.Object) - return nil } func (c *Context) FramebufferPixels(f Framebuffer, width, height int) ([]uint8, error) { diff --git a/internal/opengl/context_mobile.go b/internal/opengl/context_mobile.go index ddd51a4b5..de5c9e532 100644 --- a/internal/opengl/context_mobile.go +++ b/internal/opengl/context_mobile.go @@ -148,10 +148,9 @@ func (c *Context) NewTexture(width, height int, pixels []uint8, filter Filter) ( return Texture(t), nil } -func (c *Context) bindFramebufferImpl(f Framebuffer) error { +func (c *Context) bindFramebufferImpl(f Framebuffer) { gl := c.gl gl.BindFramebuffer(mgl.FRAMEBUFFER, mgl.Framebuffer(f)) - return nil } func (c *Context) FramebufferPixels(f Framebuffer, width, height int) ([]uint8, error) { diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index c908a7e44..7c2c12d57 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -491,9 +491,7 @@ func (u *userInterface) loop(g GraphicsContext) error { return err } // The bound framebuffer must be the default one (0) before swapping buffers. - if err := opengl.GetContext().BindScreenFramebuffer(); err != nil { - return err - } + opengl.GetContext().BindScreenFramebuffer() _ = u.runOnMainThread(func() error { u.swapBuffers() return nil