8 bpp surfaces

I hate to keep bugging this group with my newbie questions, but could
somebody tell me how to set a pixel color in 8 bpp mode.
I’ve created a pallette and set it to screen (do I need to set it to the
double buffer and the other surfaces as well?) Then I tried setting the
pixels to SDL_MapRGB with the RGB values of the index that I wanted to
color the rectangle with, but just gave me a black screen instead of the
filled rectangle that I get in all the other depths. Then I tried
passing the index of the color I wanted to make it, but that gave me a
black screen too.

I hate to keep bugging this group with my newbie questions, but could
somebody tell me how to set a pixel color in 8 bpp mode.
I’ve created a pallette and set it to screen (do I need to set it to the
double buffer and the other surfaces as well?) Then I tried setting the
pixels to SDL_MapRGB with the RGB values of the index that I wanted to
color the rectangle with, but just gave me a black screen instead of the
filled rectangle that I get in all the other depths. Then I tried
passing the index of the color I wanted to make it, but that gave me a
black screen too.

Did you look at the testwin example and the examples in the documentation?

Pseudo-code ('cause I’m tired - CivCTP 1.1 is just out)

Set video mode
Set screen palette (SDL_SetColors())
Draw with the palette indices.
i.e. SDL_FillRect(screen, NULL, SDL_MapRGB(0xFF, 0xFF, 0xFF));
Actually the above line works in all depths. In 8-bit, MapRGB maps to
a palette index.

If that doesn’t help, holler, and I’m sure other more knowledgeable
people on this list will be glad to explain it. :slight_smile:

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec