[SDL] SDL_MapRGB on big endian architectures

Eddy Cullen eac203 at ecs.soton.ac.uk
Fri May 9 02:46:05 PDT 2008


 From the SDL DocWiki:

   Uint32 SDL_MapRGB(SDL_PixelFormat *fmt, Uint8 r, Uint8 g, Uint8 b);

So unless b mean red and r means blue, what you have is a bug.

Simple as that!

   http://bugzilla.libsdl.org/

Is the answer you're looking for :)

Jitsu Love,

Eddy

list_subscribe at gmx.net wrote:
> I am doing some experiments with SDL on the Playstation 3. PS3 uses the Cell processor which consists of a PPC core and some additional stuff. So it usess big endian byte order.
> When I do a SDL_MapRGB(screen->format, 0, 0, 255) I end up with a red color. Is this intended (do I have to do swapping myself)?
> Color masks seem to be correct (e.g. 0xFF0000 for red).
> used SDL version is 1.2.10
> 
> Small test program that I used to test this:
> 
> #include <SDL/SDL.h>
> #include <stdio.h>
> 
> int main() {
>         SDL_Init(SDL_INIT_VIDEO);
>         atexit(SDL_Quit);
>         SDL_Surface* screen = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE | SDL_DOUBLEBUF);
>         SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 255));
>         SDL_Flip(screen);
>         getchar();
> }
> 



More information about the SDL mailing list