From f8ff50cfde8c23db621a47a82ad6c21f1a1b1159 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 5 Apr 2015 17:35:19 -0300 Subject: [PATCH] Fixed Image:refresh for sRGB images when OpenGL ES 2 is being used. --- src/modules/graphics/opengl/Image.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/graphics/opengl/Image.cpp b/src/modules/graphics/opengl/Image.cpp index 1b8d8d079..ecbddb2cf 100644 --- a/src/modules/graphics/opengl/Image.cpp +++ b/src/modules/graphics/opengl/Image.cpp @@ -332,9 +332,16 @@ bool Image::refresh(int xoffset, int yoffset, int w, int h) const image::pixel *pdata = (const image::pixel *) data->getData(); pdata += yoffset * data->getWidth() + xoffset; + GLenum format = GL_RGBA; + + // In ES2, the format parameter of TexSubImage must match the internal + // format of the texture. + if (flags.sRGB && (GLAD_ES_VERSION_2_0 && !GLAD_ES_VERSION_3_0)) + format = GL_SRGB_ALPHA; + { thread::Lock lock(data->getMutex()); - glTexSubImage2D(GL_TEXTURE_2D, 0, xoffset, yoffset, w, h, GL_RGBA, + glTexSubImage2D(GL_TEXTURE_2D, 0, xoffset, yoffset, w, h, format, GL_UNSIGNED_BYTE, pdata); }