Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Q: Changing colormap of texture after creation

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2003
    Posts
    3

    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?

  2. #2
    Intern Contributor
    Join Date
    Apr 2002
    Posts
    87

    Re: Q: Changing colormap of texture after creation

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

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2003
    Posts
    3

    Re: Q: Changing colormap of texture after creation

    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.

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Oct 2001
    Posts
    612

    Re: Q: Changing colormap of texture after creation

    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)

  5. #5
    Junior Member Newbie
    Join Date
    Jul 2003
    Posts
    3

    Re: Q: Changing colormap of texture after creation

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •