Color Index / RGBA

If I need to make a program work for color index and RGBA mode what’s the best way to go about this? (I do not need to change between the modes in the middle of the program; I just need a program that has the ability to function both ways)

Can I set both glColor and glIndex and not have one over-ride the other? If i can’t, is there a command that will return what color state the program was opened with?


Some warnings first: Color index is more or less dead.
“Less” because there’s still MS OpenGL and some overlay plane implementations using it. But you’re unlikely to get hardware acceleration on recent graphics boards choosing a color index pixelformat.

You cannot change the modes in the middle of a program by other means than destroying the OpenGL window and recreating another one selecting a different pixelformat.

You must know in advance what you want, because you select the pixelformat! It’s either color index or RGBA.

glIndex is doing nothing else than updating the current index in RGBA mode and glColor
does the analogous in color index mode. So there’s one definite “yes”.

You can query the mode in OpenGL by glGetBooleanv(GL_INDEX_MODE, &b); Well, but that’s redundant if you know what pixelformat you selected.

Lighting is very different in color index mode and the palette handling can be a pain.
At least MS describes how to do that in the OpenGL manual pages.

Thanks for the info.

I think that I don’t actually get to choose which mode my program is in, since I’ve been told x-windows decides color-index mode/RGBA via the user’s settings for the screen their using.