SDL_SetWindowDisplayMode not really setting video mode

First of all, congrats for the great work with SDL1.3.

I’m working in a game engine that assumes the graphic format is ordered as RGB and I’m having trouble with iOS swapping red and blue channels (this image (https://lh5.googleusercontent.com/-9IpCyrJMy8g/TmXc2YL6cCI/AAAAAAAALBk/PzcJ0y-iQcM/s800/Icon.png) shows like this (https://lh6.googleusercontent.com/-WebOHR97_70/TmXc2aB3ljI/AAAAAAAALBc/V1bDazYxJj4/s800/Captura%2520de%2520pantalla%25202011-09-04%2520a%2520la%2528s%2529%252003.42.47.png)). In the wiki I found about SDL_SetWindowDisplayMode (http://wiki.libsdl.org/moin.cgi/SDL_SetWindowDisplayMode) so I thought I’d be able to force the window to use a RGB mode instead of BGR, howevere I’ve not been able to do so.
What I’m trying is:

Code:
SDL_DisplayMode mode;

    window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, surface_width, surface_height, sdl_flags);
    
    mode.w = surface_width;
    mode.h = surface_height;
    mode.refresh_rate = 0;
    mode.driverdata   = 0;
    mode.format       = SDL_PIXELFORMAT_RGB888;
    SDL_SetWindowDisplayMode(window, &mode);

    screen = SDL_GetWindowSurface(window);

where sdl_flags is SDL_WINDOW_SHOWN|SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS.

But the image shows in BGR mode anyway. Am I doing anything wrong? Should I do something else?

Thanks in advance for your help.

whenever I run into the BGR on Mac issue it’s usually because I’m loading
the image incorrectly. What routine are you using for image loading? It
you’re creating a texture, for example, you’ll need to specify the BGR order
there as well.

hope that helps,

JohnOn Tue, Sep 6, 2011 at 4:17 AM, josebagar <joseba.gar at gmail.com> wrote:

**
First of all, congrats for the great work with SDL1.3.

I’m working in a game engine that assumes the graphic format is ordered as
RGB and I’m having trouble with iOS swapping red and blue channels (this
imagehttps://lh5.googleusercontent.com/-9IpCyrJMy8g/TmXc2YL6cCI/AAAAAAAALBk/PzcJ0y-iQcM/s800/Icon.pngshows like
thishttps://lh6.googleusercontent.com/-WebOHR97_70/TmXc2aB3ljI/AAAAAAAALBc/V1bDazYxJj4/s800/Captura%2520de%2520pantalla%25202011-09-04%2520a%2520la%2528s%2529%252003.42.47.png).
In the wiki I found about SDL_SetWindowDisplayModehttp://wiki.libsdl.org/moin.cgi/SDL_SetWindowDisplayModeso I thought I’d be able to force the window to use a RGB mode instead of
BGR, howevere I’ve not been able to do so.
What I’m trying is:

Code:

     SDL_DisplayMode mode;

    window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED,

SDL_WINDOWPOS_CENTERED, surface_width, surface_height, sdl_flags);

    mode.w = surface_width;
    mode.h = surface_height;
    mode.refresh_rate = 0;
    mode.driverdata   = 0;
    mode.format       = SDL_PIXELFORMAT_RGB888;
    SDL_SetWindowDisplayMode(window, &mode);

    screen = SDL_GetWindowSurface(window);

where sdl_flags is
SDL_WINDOW_SHOWN|SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS.

But the image shows in BGR mode anyway. Am I doing anything wrong? Should I
do something else?

Thanks in advance for your help.


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

Yes, the game engine is loading the image itself as RGB (always) but I was wondering if SDL_SetWindowDisplayMode shouldn’t help with that.

I believe I’ll have to modify the image loading mechanism to support BGR as well.

Yes, the game engine is loading the image itself as RGB (always) but I
was wondering if SDL_SetWindowDisplayMode shouldn’t help with that.

You don’t fill in an SDL_DisplayMode for that; you use one provided by
the system (SDL_GetNumDisplayModes() and SDL_GetDisplayMode()).

If you need to swizzle color data, there are other avenues for that.

–ryan.

Ok, thanks for the reply :slight_smile: