Browse Source

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

Alex Szpakowski 10 years ago
parent
commit
f8ff50cfde
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/modules/graphics/opengl/Image.cpp

+ 8 - 1
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);
 		}