Q: Changing colormap of texture after creation

After creating some textures using glBindTexture and gluBuild2DMipmaps, I would like to change or apply a colormap to the textured surfaces before they are drawn. Setting up pixel mapping only works when creating the textures, and doesn’t seem to have any effect afterwards. What I’m trying to do is to have the textures in resident memory as “raw images”, and then have a user changable colormap applied before they are rendered on surfaces. Can this be done without setting up pixel mapping and rebuilding the textures every time the colormap is changed?

Any ideas?

Couldn’t you use glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE) to modulate the texture with glColor3f() calls?

Originally posted by kansler:
Couldn’t you use glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE) to modulate the texture with glColor3f() calls?

This would work for changing the brightness and color tone of the image, but I’m also looking to improve contrast and to change selected colors. I think I would need something like the glPixelMap and glPixelTransfer functions, but applied at a later stage in the rendering process, not at creation time.
So far my solution has been to use glGetTexImage to get the texture back, then
enabling and setting pixel mapping, followed by glTexSubImage2D. The problem with this, is that when I read back the texture a second time, the pixels will be the modified ones, not the original “raw” image.

the pixeltransfer = color*scale+bias…

if you use 2 texture units you can do that in realtime as well

use reg combiners and GL_MODULATE in the first step, and GL_ADD ( or GL_ADD_SIGNED if you need to subtract as well)

Seems that SGI has an extension that does this by using glPixelTransfer with GL_TEXTURE_COLOR_TABLE_SGI, but this extension is not implemented on my system. Multi-texture and register combiners are, so I’ll look into that.