Fixed Image:refresh for sRGB images when OpenGL ES 2 is being used.

This commit is contained in:
Alex Szpakowski
2015-04-05 17:35:19 -03:00
parent cf0968fc6d
commit f8ff50cfde
+8 -1
View File
@@ -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);
}