PDA

View Full Version : glDrawPixels with GL_COLOR_INDEX



steve_j
09-05-2006, 12:09 AM
Hi!

I just can't get my code working to draw anything with glDrawPixels.

Following situation: I have color index image data with GL_UNSIGNED_BYTE and want to draw the data with glDrawPixels. I have set up a color map for mapping the color indices to RGBA but without any success. Here is the relevant code:


glPixelTransferi(GL_MAP_COLOR,GL_TRUE);

GLfloat redMap[8] = {0.,0.,1.,1.,1.,0.,0.,0.};
GLfloat greenMap[8] = {0.,1.,1.,0.,0.,0.,0.,0.};
GLfloat blueMap[8] = {0.,0.,0.,0.,1.,0.,0.,0.};
GLfloat alphaMap[8] = {0.,1.,1.,1.,1.,0.,0.,0.};

glPixelMapfv(GL_PIXEL_MAP_I_TO_R,8,&redMap[0]);
glPixelMapfv(GL_PIXEL_MAP_I_TO_G,8,&greenMap[0]);
glPixelMapfv(GL_PIXEL_MAP_I_TO_B,8,&blueMap[0]);
glPixelMapfv(GL_PIXEL_MAP_I_TO_A,8,&alphaMap[0]);

glRasterPos2f(0.f,0.f);
glDrawPixels(wxrImage->getWidth(),wxrImage->getHeight(),GL_COLOR_INDEX,GL_UNSIGNED_BYTE,wxrIma ge->getImageData());

glPixelTransferi(GL_MAP_COLOR,GL_FALSE);WxrImage:: getImageData returns const unsigned char* of size wxrImage->getWidth()*wxrImage->getHeight()

Has anyone a hint what's wrong here? Trying the same with glTexImage2D works.

Thanks,
steve

Brian Paul
09-05-2006, 04:04 PM
Did you enable your pixel maps with glPixelTransferi(GL_MAP_COLOR, GL_TRUE)?

Brian Paul
09-05-2006, 04:06 PM
Oops, I see that you did at the top.

Whose OpenGL driver are you using?

steve_j
09-05-2006, 11:54 PM
glxinfo tells me GL version string is 1.3.5461

Relic
09-06-2006, 02:28 AM
That means you run an NVIDIA Linux driver version 54.61?
You should try more up-to-date drivers.
http://www.nvidia.com/object/unix.html