PDA

View Full Version : glPixelMap - no effect in textures



11-16-2005, 04:28 AM
I am trying to use pixel mapping in textures. However, glPixelMap doesn't have any effect on textures. The textures are rendered with the same colors as without calling glPixelMap, regardless of the mapping set with glPixelMap.


// setting pixel map (lutdata is the array of floats scaled between 0 and 1)

glPixelTransferf(GL_MAP_COLOR, true); glPixelMapfv(GL_PIXEL_MAP_R_TO_R,256,lutdata[0]);
glPixelMapfv(GL_PIXEL_MAP_G_TO_G,256,lutdata[1]);
glPixelMapfv(GL_PIXEL_MAP_B_TO_B,256,lutdata[2]);


// creating textures

glEnable(GL_TEXTURE_2D);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGB, type, data);


// drawing

glBindTexture(GL_TEXTURE_2D, tex);
...What could be wrong? According to the documentations, glTexImage2D should use the translation table set by glPixelMap. In my tests, it doesn't give any effect.

charliejay
11-18-2005, 02:17 AM
Tried somthing similar recently, and when my compiler complained that I was passing an incompatible type (GLubyte, which worked) for the array of map values into glPixelMap, which wants a GLuint, or a GLfloat, if I remember correctly, I tried GLuint, which didn't work, and just drew my textured polygon in the original colours.

Try making your array of GLfloats into GLubytes instead (you might need to force the compiler to accept this, by setting the appropriate flag; mine just throws a warning)...

CJ