PDA

View Full Version : Textures (identical to BMP file)



Thomas Alton
01-10-2009, 12:34 PM
Hi,

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?

ZbuffeR
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.

Thomas Alton
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:
glDisable(GL_LIGHTING);
glDisable(GL_BLEND);

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?

ZbuffeR
01-11-2009, 02:53 AM
No more ideas.
screenshots please.

Thomas Alton
01-11-2009, 04:23 AM
Original BMP file:
http://i40.tinypic.com/23r0650.jpg
OpenGL result:
http://i39.tinypic.com/25sabh1.jpg

In another test I made, I created a BMP file with four rectangles.

The RGB values for the rectangles in BMP were:
100,100,100
110,110,110
120,120,120
200,200,200

In openGL texture the RGB values of the rectangles were:
99,101,99
107,109,107
123,121,123
206,203,206

ZbuffeR
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 ?

Thomas Alton
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!

ZbuffeR
01-11-2009, 10:14 AM
Indeed, GL_RGB is older and deprecated, as it does not specify the number of bits.