Color reduction problem with textures

Hi,

got a problem with textures. On a tnt2 I get the 24-bit texture as I specified it. On a tnt with the same code I get the texture in 16 colors. But the display has 24-bit (I render a cylinder in front of the background-texture and it has smooth transitions).

Here is the source I use to initialize the texture:

    glPixelStorei(GL_UNPACK_ALIGNMENT,   1);

  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // low: GL_NEAREST, high: GL_LINEAR.
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // low: GL_NEAREST, high: GL_LINEAR.

  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

  glTexImage2D(GL_TEXTURE_2D, 0, 4, imgWidth, imgHeight, 0,
       GL_RGBA, GL_UNSIGNED_BYTE, imgRaster);
  
  glEnable(GL_TEXTURE_2D);

Any suggestions?

[This message has been edited by Kilam Malik (edited 11-11-2000).]

glTexImage2D(GL_TEXTURE_2D, 0, 4, imgWidth, imgHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, imgRaster);

You’ve got a number ‘4’ where you should be specifying an internal texture format hint. Try GL_RGB8 if you’re not using an alpha channel and see what happens.

<edit>: Oops! I forgot to mention that your driver is allowed to ignore this if it wants too

Paul.

[This message has been edited by Pauly (edited 11-11-2000).]

The SuperBible, MSDN Help and NeHe’s Tutorial tells me to insert the number of values per pixel as third parameter. So I used 4 as I have an alpha value. What define
should I use in your opinion with 4 components for each color as byte, as GL_RGB8 is for RGB only?

Kilam.

Your documentation is out of date. 1, 2, 3, and 4 are defined to be equivalent to GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, and GL_RGBA, respectively.

Try GL_RGBA8.

  • Matt

Thank you both, that was the solution :wink: