View Full Version : color maps in OpenGL
I had asked earlier this month about animation in OpenGL and the animation that I produced is in grayscale. The problem seems to be that I don't have RGB values for the images just single integers from 0 to 255 that I put into the RGB array. I thought of using color-index mapping but I'm at a loss on how to generate a lookup table. Is it that OpenGL has its own internal lookup table or I can specify mine. If I could specify my own color map, how do I implement this ( I am thinking of using the glIndex function).
If you use indexed colour, you will loose hardware acceleration. To achieve the grayscale effect in higher colour modes as 16 or 32 bit, do this:
I suppose your color maps work like this: 0 is black and 255 is white. Then you must enter the three RGB values as
in OpenGL functions.
where "i" is the index of your colour.
[This message has been edited by Azdo (edited 04-27-2002).]
Thanks for your reply but I have a different problem. I have an image which can be expressed as a 296x128 pixel array. This represents a density map and there is only one value of the density per pixel( so to speak). Please see the topic in this forum 'Animation using OpenGL' by Otonski.
My solution was to give the same density value to the RGB array ie red = 255, green = 255, blue = 255. That produced the grayscale image( notice they are integers). I thought using a color map where a number say 202 generates an RGB triplet may be the solution to making a color image.
Originally posted by Otonski:
Please see the topic in this forum 'Animation using OpenGL' by Otonski.
So you are saying that you don't want a monochrome image but a colormap which holds the "density" of the image. I think this can't be done easily from the image. You must preprocess your data, then use it with OpenGL
Originally posted by Azdo:
You must preprocess your data, then use it with OpenGL
You can, for example, set the range of all your values between 0 and 0x00FFFFFF by dividing all your values by 255, then multiplying them by 0x00FFFFFF. The purpose is to have the RGB values of the colour. If red and green values are zero, then use only the blue value:
if (color&0xFFFF00==0) color=color&0xFF;
The same with the green and red values.
If I find a better algorithm, I'll let you know.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.