PDA

View Full Version : Textures-reduced to 4 bits per color?



Zoran Zivkovic
08-16-2000, 08:17 AM
If I look to the histogram of the textured images I can conlcude that there are only 4 bits to code the colors of the textures.
(I use GL_NEAREST and a textured object over the whole screen - with GL_REPLACE to see thid effect)

How it could be changed?


Here is the code:

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

glGenTextures(1,&m_myTexture);
glBindTexture(GL_TEXTURE_2D,m_myTexture);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL _REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL _REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_NEAREST);

glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_REPLACE);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, columns,rows, 0, GL_RGBA, GL_UNSIGNED_BYTE,
(unsigned char*)checkImage);

Bob
08-16-2000, 09:01 AM
This happens because you choose GL_RGBA as internal texture format. GL_RGBA tells OpenGL to use RGBA format, but not how many bits, so it's up to the driver to choose the EXACT pixelformat. This can be solved by setting the exact pixelformat yourself, for example, choose GL_RGBA8 (or whatever it's called). This will "force" OpenGL to use 8 bits per element. However, if your driver can't use 32-bit internal texture formats, it will choose another anyway.

Zoran Zivkovic
08-17-2000, 01:32 AM
Thank you Bob! I should have looked it up better in the Red Book.