From 5da6bc645029d211cfc64596c3e5377a3e76f981 Mon Sep 17 00:00:00 2001 From: yvt Date: Fri, 23 Aug 2013 15:10:49 +0900 Subject: [PATCH] SRGB --- ChangeLog | 3 +++ Sources/Draw/GLRenderer.cpp | 11 ++++++++++- Sources/Draw/IGLDevice.h | 1 + Sources/Gui/SDLGLDevice.cpp | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2e8d9691..e64634fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -42,5 +42,8 @@ * FXAA * GUI fix +2013-08-23 yvt + + * Support SRGB diff --git a/Sources/Draw/GLRenderer.cpp b/Sources/Draw/GLRenderer.cpp index 157d866e..f2eb63de 100644 --- a/Sources/Draw/GLRenderer.cpp +++ b/Sources/Draw/GLRenderer.cpp @@ -52,6 +52,7 @@ SPADES_SETTING(r_optimizedVoxelModel, "1"); SPADES_SETTING(r_radiosity, "0"); SPADES_SETTING(r_fogShadow, "0"); SPADES_SETTING(r_fxaa, "1"); +SPADES_SETTING(r_srgb, "1"); namespace spades { @@ -319,7 +320,8 @@ namespace spades { device->Enable(IGLDevice::DepthTest, true); device->Enable(IGLDevice::Texture2D, true); - + if(r_srgb) + device->Enable(IGLDevice::FramebufferSRGB, false); } @@ -489,6 +491,9 @@ namespace spades { device->Enable(IGLDevice::Blend, true); + if(r_srgb) + device->Enable(IGLDevice::FramebufferSRGB, true); + device->DepthMask(false); if(!r_softParticles){ // softparticle is a part of postprocess device->BlendFunc(IGLDevice::One, @@ -536,6 +541,10 @@ namespace spades { if(r_fxaa) handle = GLFXAAFilter(this).Filter(handle); + + if(r_srgb) + device->Enable(IGLDevice::FramebufferSRGB, false); + // copy buffer to WM given framebuffer device->BindFramebuffer(IGLDevice::Framebuffer, 0); device->Enable(IGLDevice::Blend, false); diff --git a/Sources/Draw/IGLDevice.h b/Sources/Draw/IGLDevice.h index 08e16d94..1b76ecc4 100644 --- a/Sources/Draw/IGLDevice.h +++ b/Sources/Draw/IGLDevice.h @@ -35,6 +35,7 @@ namespace spades { CullFace, Blend, Multisample, + FramebufferSRGB, // Parameters FramebufferBinding, diff --git a/Sources/Gui/SDLGLDevice.cpp b/Sources/Gui/SDLGLDevice.cpp index 10598601..b42d19b4 100644 --- a/Sources/Gui/SDLGLDevice.cpp +++ b/Sources/Gui/SDLGLDevice.cpp @@ -133,6 +133,7 @@ namespace spades { case Blend: type = GL_BLEND; break; case Texture2D: type = GL_TEXTURE_2D; break; case Multisample: type = GL_MULTISAMPLE; break; + case FramebufferSRGB: type = GL_FRAMEBUFFER_SRGB; break; default: SPInvalidEnum("state", state); } if(b)