http://bugs.winehq.org/show_bug.cgi?id=59436 --- Comment #2 from tpaniaki <tpaniaki@protonmail.com> --- Comment on attachment 80417 --> http://bugs.winehq.org/attachment.cgi?id=80417 Patch
diff --git a/dlls/opengl32/thunks.c b/dlls/opengl32/thunks.c index 3c60ec5d6bb..7145c2c1b7f 100644 --- a/dlls/opengl32/thunks.c +++ b/dlls/opengl32/thunks.c @@ -3207,8 +3207,45 @@ static void WINAPI glBindFramebuffer( GLenum target, GLuint framebuffer ) { struct glBindFramebuffer_params args = { .teb = NtCurrentTeb(), .target = target, .framebuffer = framebuffer }; NTSTATUS status; + static BOOL srgb_disabled_for_default_fb; + TRACE( "target %d, framebuffer %d\n", target, framebuffer ); if ((status = UNIX_CALL( glBindFramebuffer, &args ))) WARN( "glBindFramebuffer returned %#lx\n", status ); + + if (target == GL_DRAW_FRAMEBUFFER || target == GL_FRAMEBUFFER) + { + struct glIsEnabled_params is_enabled_args = { .teb = NtCurrentTeb(), .cap = GL_FRAMEBUFFER_SRGB }; + GLboolean srgb_enabled; + + if ((status = UNIX_CALL( glIsEnabled, &is_enabled_args ))) WARN( "glIsEnabled returned %#lx\n", status ); + srgb_enabled = is_enabled_args.ret; + + if (!framebuffer) + { + /* Avoid double sRGB/gamma conversion on the onscreen framebuffer. */ + if (srgb_enabled) + { + struct glDisable_params disable_args = { .teb = NtCurrentTeb(), .cap = GL_FRAMEBUFFER_SRGB }; + + TRACE( "disabling GL_FRAMEBUFFER_SRGB on default framebuffer\n" ); + if ((status = UNIX_CALL( glDisable, &disable_args ))) WARN( "glDisable returned %#lx\n", status ); + srgb_disabled_for_default_fb = TRUE; + } + else + { + srgb_disabled_for_default_fb = FALSE; + } + } + else if (srgb_disabled_for_default_fb) + { + /* Restore sRGB state for offscreen FBOs if we disabled it for FBO 0. */ + struct glEnable_params enable_args = { .teb = NtCurrentTeb(), .cap = GL_FRAMEBUFFER_SRGB }; + + TRACE( "restoring GL_FRAMEBUFFER_SRGB on non-default framebuffer\n" ); + if ((status = UNIX_CALL( glEnable, &enable_args ))) WARN( "glEnable returned %#lx\n", status ); + srgb_disabled_for_default_fb = FALSE; + } + } }
static void WINAPI glBindFramebufferEXT( GLenum target, GLuint framebuffer )
-- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.