PDA

View Full Version : Paletted Rasterizing



08-06-2001, 03:59 PM
Does someone have some code to show me how to set the palette when using this function:

glDrawPixels(BitmapInfo->bmiHeader.biWidth, BitmapInfo->bmiHeader.biHeight, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, BitmapBits);

It works when i use GL_LUMINANCE as Color format but that only shows grayscale... so help me with this please http://www.opengl.org/discussion_boards/ubb/smile.gif

08-07-2001, 05:33 AM
I think that the palette functions is part of the OS. Perhaps somw wgl or GDI functions on Windows?

08-07-2001, 08:06 AM
Nope its not OS specific... I though this was an easy question to answer?... Should i post in the advanced forum to get an good reply or what?

08-07-2001, 10:41 AM
If you think you know why do you ask?

From a OpenGL book
"OpenGL does not have any routines to load values into the color-lookup table. Window systems typically already have such operations."
You can read the documentation yourself.

Remember that nobody have to give you a good or any kind of reply.

08-07-2001, 11:08 AM
Well maybe i dont want to load a palette...

All i want to know is how to attach a palette to a glDrawPixels operation!

08-07-2001, 12:47 PM
Nevermind i fixed it somehow...

Heres the code if anyone wondered what i was actually doing...

int i;

for(i=0;i<256; i++)
{
red[i] = BitmapInfo->bmiColors[i].rgbRed<<8;
green[i] = BitmapInfo->bmiColors[i].rgbGreen<<8;
blue[i] = BitmapInfo->bmiColors[i].rgbBlue<<8;
}

glPixelTransferi(GL_MAP_COLOR, TRUE);

glPixelMapusv(GL_PIXEL_MAP_I_TO_R, 256,(const unsigned short *)&red );
glPixelMapusv(GL_PIXEL_MAP_I_TO_G, 256, (const unsigned short *)&green);
glPixelMapusv(GL_PIXEL_MAP_I_TO_B, 256, (const unsigned short *)&blue);

glDrawPixels(BitmapInfo->bmiHeader.biWidth,
BitmapInfo->bmiHeader.biHeight,
GL_COLOR_INDEX, GL_UNSIGNED_BYTE, BitmapBits);

Now its working fine!