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: 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): 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);
}
GL_SRGB_EXT
instead ofGL_RGB
toglTexImage2D
, 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\$