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.