I'm having some issues loading in textures in OpenGL, as my textures keep rendering incorrectly or coming out looking muddy. For instance, here I tried to load a 256x256 color spectrum image. On the left is how it looks in OpenGL and on the right is how it looks in an image viewing program: Texture Issue 1 As you can see, while the left image resembles the right image, the left image appears to squish the blues, and greens, and extend the pinks.

I also tried loading in this 512x512 image of a dog and the result came out like this (again, left is OpenGL, right is image viewer): Texture Issue 2 For this image, the image looks like it has lost a lot of its color, resulting in something that looks white washed and like it came out of a 1970s camera. (the fact that is flipped is fine however since the cube that I am drawing this on has some texture coordinates flipped to accommodate for a different image).

I load in these .BMP textures using SOIL, as such: glEnable(GL_TEXTURE_2D);

GLuint texID = 0;
glGenTextures(1, &texID);

int height = 0, width = 0;
unsigned char* imgData = SOIL_load_image(filePath.c_str(), &width, &height, 0, SOIL_LOAD_AUTO); 

glBindTexture(GL_TEXTURE_2D, texID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, imgData);
// set texture filtering, gen mip map

Then in my fragment shader I do the following to apply the texture:

#version 330 core
in vec2 TexCoord;

uniform sampler2D textureSampler;

void main() {
    gl_FragColor = texture2D(textureSampler, TexCoord);
  • \$\begingroup\$ Is gamma correction applied? \$\endgroup\$
    – Ocelot
    Commented Oct 19, 2016 at 15:53
  • \$\begingroup\$ @Ocelot Yes, I used glEnable(GL_FRAMEBUFFER_SRGB) to enable OpenGL's gamma correction. \$\endgroup\$ Commented Oct 19, 2016 at 15:56
  • \$\begingroup\$ Have you also enabled sRGB reads from your texture/sampling state? You might accidentally be mixing linear and gamma corrected colours. \$\endgroup\$
    – DMGregory
    Commented Oct 19, 2016 at 16:10
  • \$\begingroup\$ @DMGregory I don't think so, I'm not really sure what you mean, though... How would I enable sRGB reading from the texture? \$\endgroup\$ Commented Oct 19, 2016 at 16:15
  • 1
    \$\begingroup\$ I'm not fluent in OpenGL, but quoting this GPU Gems article, "Passing GL_SRGB_EXT instead of GL_RGB to glTexImage2D, for example, ensures that any shader accesses to the specified texture return linear pixel values." Check if that works for you, and we can write it up as an answer if that turned out to be the culprit. \$\endgroup\$
    – DMGregory
    Commented Oct 19, 2016 at 16:55

1 Answer 1


This has been solved in the comments, but for everyone comming here: I had the same problem that textures appeared washed out on certain (Intel?) GPUs. It turned out that OpenGL had enabled GL_FRAMEBUFFER_SRGB by default on some hardware. Calling glDisable(GL_FRAMEBUFFER_SRGB) right after context creation fixed it for me.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .