[SDL] Determine player's video's color depth...

Stephen Anthony stephena at roadrunner.nf.net
Mon Nov 10 09:12:01 PST 2003

On November 10, 2003 01:21 pm, Rico "Zuñiga" wrote:
> I have just found out what's slowing down the the graphics in a game
> i'm making - setting the viedo to 32 bits per pixel, whereas my video
> can only support up to 24 bits per pixel. You might think this is
> stupid of me not realizing this sooner, but i'm a newbie and was just
> following the tutorial verbatim. So anyway after setting it to 24 bits,
> my game performed really well. My question now is how can I determine
> the appropriate bits per pixel to set for the other people who would
> play my game. Is there a way to determine (dynamically) the video
> settings of other people's machines.

I don't think there is a way to do that.  What I do is open the window and 
specify '0' for the depth, which means open at the current depth.  Then, 
you adjust your colors for that depth, which can be read from the nely 
created SDL surface.

So if your game is palette-based, there should be provisions made for 
8/15/16/24/32 bit color.  Some of these may be the same (15/16), or some 
may be unnecessary to test for (8), but the only practical way to do it 
is (1) restrict your game to a specific depth, or (2) accommodate all of 


More information about the SDL mailing list