View Full Version : Image Drawing

01-15-2004, 11:54 PM

I would like to draw an Image using glReadPixels.

The problem is I have the color values for my pixels not in different RGB values but in one byte per pixel.

I tried with GL_COLOR_INDEX but it is not working.

Could anyone give me a hint?

Thanks, Andrei.

01-16-2004, 12:57 AM
First, use glDrawPixels. http://www.opengl.org/discussion_boards/ubb/wink.gif
If the unsigned char is a greyscale, you can use GL_LUMINANCE.
If the unsigned char is an index into a palette (a color image like GIF) and you are in an OpenGL RGBA pixelformat (most likely, almost noone supports color indexed rendering in HW) you need to set up a palette lookup for the colors.
Look at glPixelTransfer and glPixelMap.
Don't expect good performance.

OpenGL function reference is here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/apxb4_82lh.asp