SDL_MapRGB on big endian architectures

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();
}–
Psssst! Schon vom neuen GMX MultiMessenger geh?rt?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger

Hello !

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

SDL 1.2.10 is really old, please
try the latest SDL version from the website ?

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();
}

Do you run SDL under a PS3 Linux distro ?

CU

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)?

No, you shouldn’t have to do that yourself.On Tue, Apr 22, 2008 at 11:39 AM, <list_subscribe at gmx.net> wrote:

Color masks seem to be correct (e.g. 0xFF0000 for red).
used SDL version is 1.2.10

Hello !

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

SDL 1.2.10 is really old, please
try the latest SDL version from the website ?

I used the one that came with my distro. I manually compiled and installed
1.2.13 - the result is the same.

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(); }

Do you run SDL under a PS3 Linux distro ?

I use Yellow Dog Linux on the PS3.On Tue, April 22, 2008 12:59 pm, Torsten Giebl wrote:

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 :slight_smile:

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();
}

As it turns out I really found a bug, but not in SDL.

I have no HDCP enabled display (ps3 requires that) so I used VNC to
connect to the X Server on the PS3. X looked normal, but the contents of
any SDL window had swapped colors. Seems like some part of X11vnc has
problems with the byteorder.

Sorry for the false alarm…On Fri, May 9, 2008 11:46 am, Eddy Cullen wrote:

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 :slight_smile:

Jitsu Love,

Eddy

@list_subscribe_at_gm 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(); }


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org