From 3abc891680c6b9cfaa2e67b240b3d80c8c9ba5c9 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Tue, 5 Oct 2021 08:22:52 +0200 Subject: [PATCH] gpu/internal/opengl: [OpenGL] respect render target when emulating sRGB Before this change, the sRGB emulation target would always be the current framebuffer. Now it's the render target passed to BeginFrame. Signed-off-by: Elias Naur --- gpu/internal/opengl/opengl.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gpu/internal/opengl/opengl.go b/gpu/internal/opengl/opengl.go index 5c6ec123..af4a673c 100644 --- a/gpu/internal/opengl/opengl.go +++ b/gpu/internal/opengl/opengl.go @@ -35,7 +35,8 @@ type Backend struct { srgbaTriple textureTriple storage [storageBindings]*buffer - sRGBFBO *SRGBFBO + outputFBO gl.Framebuffer + sRGBFBO *SRGBFBO // vertArray is bound during a frame. We don't need it, but // core desktop OpenGL profile 3.3 requires some array bound. @@ -234,6 +235,7 @@ func (b *Backend) BeginFrame(target driver.RenderTarget, clear bool, viewport im panic(fmt.Errorf("opengl: invalid render target type: %T", target)) } } + b.outputFBO = renderFBO b.glstate.bindFramebuffer(b.funcs, gl.FRAMEBUFFER, renderFBO) if b.gles { // If the output framebuffer is not in the sRGB colorspace already, emulate it. @@ -275,7 +277,7 @@ func (b *Backend) BeginFrame(target driver.RenderTarget, clear bool, viewport im func (b *Backend) EndFrame() { if b.sRGBFBO != nil { - b.glstate.bindFramebuffer(b.funcs, gl.FRAMEBUFFER, b.savedState.drawFBO) + b.glstate.bindFramebuffer(b.funcs, gl.FRAMEBUFFER, b.outputFBO) if b.clear { b.SetBlend(false) } else {