SDL_AllocSurface

Why does SDL_AllocSurface ask for red, green, and blue masks when the depth
argument ultimately defines them?

Paul Lowe
spazz at ulink.net

Why does SDL_AllocSurface ask for red, green, and blue masks when the depth
argument ultimately defines them?

Some video cards have red, green, and blue in odd orders. For example,
32-bit RGB (0x00FF0000, 0x0000FF00, 0x000000FF) could also be:
32-bit BGR (0x000000FF, 0x0000FF00, 0x00FF0000), or:
32-bit RGBA (0xFF000000, 0x00FF0000, 0x0000FF00)

The masks allow you to specify which of these RGB orders is being used.

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

Sam Lantinga wrote:

Why does SDL_AllocSurface ask for red, green, and blue masks when the depth
argument ultimately defines them?

Some video cards have red, green, and blue in odd orders. For example,

Like which cards? Really ghetto ones from like 1990? Or the modern ones?

32-bit RGB (0x00FF0000, 0x0000FF00, 0x000000FF) could also be:
32-bit BGR (0x000000FF, 0x0000FF00, 0x00FF0000), or:
32-bit RGBA (0xFF000000, 0x00FF0000, 0x0000FF00)

The masks allow you to specify which of these RGB orders is being used.

Sam: I know this should be in some other list or something but…did you ever
decide to split up the SDL library so dynamic loading wouldn’t be necessary?

Paul Lowe
spazz at ulink.net

Some video cards have red, green, and blue in odd orders. For example,

Like which cards? Really ghetto ones from like 1990? Or the modern ones?

I’m not sure. Apparently modern ones, but I haven’t seen many that do that.

Sam: I know this should be in some other list or something but…did you ever
decide to split up the SDL library so dynamic loading wouldn’t be necessary?

Nope. The only two really independent pieces of SDL are audio and video.i
Most applications I work with use both. Cliff pointed out that demand-paged
memory management systems (like those used in Linux and Win32) do not load
an executable page from disk until it’s used, so the memory footprint shouldn’t
be very high for applications that only use one or the other.

Ack! I’m starting to talk like a techie! Stop me now!! :slight_smile:

-Sam Lantinga				(slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/