Support sRGB color space in RenderTexture
When the sf::ContextSettings asks for an sRGB capable buffer, set the rendered image to sRGB mode and convert pixels when drawing. This is the choice of simplicity compared to actually support textures with more color depth.
This commit is contained in:
parent
9e27096c37
commit
ade4a3912a
@ -58,6 +58,9 @@ bool RenderTexture::create(unsigned int width, unsigned int height, bool depthBu
|
||||
////////////////////////////////////////////////////////////
|
||||
bool RenderTexture::create(unsigned int width, unsigned int height, const ContextSettings& settings)
|
||||
{
|
||||
// Set texture to be in sRGB scale if requested
|
||||
m_texture.setSrgb(settings.sRgbCapable);
|
||||
|
||||
// Create the texture
|
||||
if (!m_texture.create(width, height))
|
||||
{
|
||||
|
@ -296,6 +296,7 @@ bool RenderTextureImplFBO::create(unsigned int width, unsigned int height, unsig
|
||||
#ifndef SFML_OPENGL_ES
|
||||
|
||||
// Create the multisample color buffer
|
||||
bool srgb = settings.sRgbCapable && GLEXT_texture_sRGB;
|
||||
GLuint color = 0;
|
||||
glCheck(GLEXT_glGenRenderbuffers(1, &color));
|
||||
m_colorBuffer = static_cast<unsigned int>(color);
|
||||
@ -305,7 +306,7 @@ bool RenderTextureImplFBO::create(unsigned int width, unsigned int height, unsig
|
||||
return false;
|
||||
}
|
||||
glCheck(GLEXT_glBindRenderbuffer(GLEXT_GL_RENDERBUFFER, m_colorBuffer));
|
||||
glCheck(GLEXT_glRenderbufferStorageMultisample(GLEXT_GL_RENDERBUFFER, settings.antialiasingLevel, GL_RGBA, width, height));
|
||||
glCheck(GLEXT_glRenderbufferStorageMultisample(GLEXT_GL_RENDERBUFFER, settings.antialiasingLevel, srgb ? GL_SRGB8_ALPHA8_EXT : GL_RGBA, width, height));
|
||||
|
||||
// Create the multisample depth/stencil buffer if requested
|
||||
if (settings.stencilBits)
|
||||
|
Loading…
Reference in New Issue
Block a user