Hi, i’m having some troubles with sRGB textures. Here’s my code to create the texture:
...
g_gammaTexture = glGenTextures();
glBindTexture(GL_TEXTURE_2D, g_gammaTexture);
for (int mipmapLevel = 0; mipmapLevel < pImageSet.getMipmapCount(); mipmapLevel++) {
SingleImage image = pImageSet.getImage(mipmapLevel, 0, 0);
Dimensions dims = image.getDimensions();
glTexImage2D(GL_TEXTURE_2D, mipmapLevel, GL_SRGB8, dims.width, dims.height, 0,
GL12.GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, image.getImageData());
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, pImageSet.getMipmapCount() - 1);
glGenerateMipmap(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 0);
If you want to see the rest of the code: https://github.com/rosickteam/OpenGL/blob/master/rosick/mckesson/IV/tut16/GammaCheckers02.java
This http://www.arcsynthesis.org/gltut/Texturing/Tut16%20Mipmaps%20and%20Linearity.html is the tutorial i am rewriting using LWJGL, i suggest to quickly read it to understand my problem.
Now i’m asking you any advice you can give me for using sRGB…am i generating mipmaps in the correct way?
I think the problem is i am not loading the texture correctly…could the error be caused by a wrong bytebuffer(image.getImageData())?
I’ve checked it a lot of times and it seems correct to me…
To summarize, here is what i get:
http://www.arcsynthesis.org/gltut/Texturing/Gamma%20Checkers.png
and here is what the texture should be:
http://desmond.imageshack.us/Himg408/scaled.php?server=408&filename=immaginerzj.png&res=medium
Any help is greatly appreciated.