Textures (identical to BMP file)

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?

completely disable bilinear filtering, disable lighting and blending, be sure to draw your texture at the exact size needed.

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?

No more ideas.
screenshots please.

Original BMP file:

OpenGL result:

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

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 ?

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!

Indeed, GL_RGB is older and deprecated, as it does not specify the number of bits.