SDL start

Hello, I finally got SDL Linked up and ready to go and am now disecting the code as much as i can from lazyfoo's site. So i was wondering.
screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );

I was wondering why is it that when i change the 32 bit to something like 8 bit. my image still shows colors. I was expecting it to be grayscale at 8bit.

EDIT: And why the program crashes when i try to go below 8bit like 4 and 2 and 1 bit?
Last edited on
I may be wrong, but I think 8 bit colour works with a palette. So, rather than referring to actual RGBA values as with 16bit/32bit colour modes, the 8 bit colour codes just refer to predefined colour values in a table.

Hope this helps.
so what difference does it make when i set the values to other than 32?
Well 32bit colour is the standard now, I think. I don't see why you would want to go lower. I assume it saves memory, but that's not as important nowadays. 32bit will presumably be higher quality.

EDIT: Forget that thing about 64 bit colours. I was thinking of something else.
Last edited on
no no i understand that, what i am trying to say is that i see no difference on the screen when i use 8bit and 32 bit color and am just curious as to why
What are you drawing to the screen? Perhaps it has fewer than 256 colours in it.
Ooooh okay now that you said that i understand..

I Thought 8 bit only means it supports the grayscale colors. So you can use any color in the world on 8 bit as long as the whole image within 256 colors?
Last edited on
Sorry. I wasn't very clear. I'm pretty sure it's not quite like that. The palette is predefined so no, I don't think it would be the case with any image with only 256 colours. I was just wondering if your image only contained colours from the palette.

There's a picture of a palette here http://en.wikipedia.org/wiki/8-bit_color.
Last edited on
Pretty much, yes.
So you *can* use any 256 colours? Does that mean the palette is constructed per image at runtime?

Surely that can't be the case for the display surface in SDL, because it doesn't know which colours are going to be drawn to it.
okay well thanks. i get it now more or less. Now to figure out why tutorial 2 doesnt recognize #include <string> ...

EDIT: @Xander314 i think what you said about predetermined pallete makes sense
Last edited on
I'm not sure any more. I think hanst suggested that there isn't a predetermined palette. He probably knows more about it than me.
Topic archived. No new replies allowed.