View Full Version : Textures (identical to BMP file)
01-10-2009, 12:34 PM
I'm playing around with Textures and would really appreciate it if someone could help me with the following:
I have a 128x128 BMP file that I use as a texture. I want the texture to be shown in an openGL application exactly like the BMP image. That is I want the same RGB value for each pixels.
In my application the texture looks quite similar to the BMP file. But when I look at it closer (pixel for pixel), I see there are small differences in the RGB values for each pixels.
Is there some settings that can make the texture identical to the BMP image pixel for pixel?
01-10-2009, 02:04 PM
completely disable bilinear filtering, disable lighting and blending, be sure to draw your texture at the exact size needed.
01-10-2009, 04:48 PM
Thank you very much for your reply, but I still can not get it to work.
I have disabled lighting and blending with the following:
I don't know how to completly disable bilinear filtering, but I use the following lines:
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
The texture is also drawn in the exact same size as the BMP file, but the colors of the texture and BMP file still differs.
Any other settings I can be missing?
01-11-2009, 02:53 AM
No more ideas.
01-11-2009, 04:23 AM
Original BMP file:
In another test I made, I created a BMP file with four rectangles.
The RGB values for the rectangles in BMP were:
In openGL texture the RGB values of the rectangles were:
01-11-2009, 08:06 AM
That is some pretty heavy color banding.
Be sure to request (and get) at least 8 bits per color channel per pixel.
If you draw a color gradient without texture, only with glColor from black to white, do you still see the color banding ?
Check how you upload your texture to OpenGL (color bits parameters, etc).
What is your video chip ? Nvidia, ATI, intel ?
01-11-2009, 08:57 AM
The problem seemed to be number of bits per color channel.
When I changed the internalFormat parameter for the glTexImage2D function from GL_RGB to GL_RGB8 everything worked fine.
Thank you very much for your help! I really appreciate it!
01-11-2009, 10:14 AM
Indeed, GL_RGB is older and deprecated, as it does not specify the number of bits.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.