I'm trying to figure out why calling SDL_GetWindowPixelFormat is returning SDL_PIXELFORMAT_RGB888, even though I'm creating the window with the flag "SDL_WINDOW_FULLSCREEN_DESKTOP", and my desktop uses 32-bit color.

Perhaps I'm misunderstanding what this flag means. I'm running my program on a Windows 7 machine, and I checked the display color-depth using Control Panel -> Display -> Adjust Resolution -> Advanced Settings -> Monitor (which displays "50 Hz, True Color 32-bit".)

I'm coding using SDL2 (version 2.0.6). I was expecting this call to return SDL_PIXELFORMAT_RGB8888 or some other 32-bit format. Any help appreciated on clarifying this. My code is below.

#include "SDL2/SDL.h"
#include <stdio.h>

SDL_Window* window;

int main(int argc, char* args[]) {


    window = SDL_CreateWindow("TUTOR", 

    Uint32 global_pixel_format = SDL_GetWindowPixelFormat(window);
    const char* temp = SDL_GetPixelFormatName(global_pixel_format);
    printf(" SDL_Window created with pixel format %s\n", temp);


    return 0;
  • \$\begingroup\$ Typically 32-bit colour on desktops means 8 red, 8 green, 8 blue and the remainder unused. Likewise, several APIs will report "RGB" or "R8G8B8", which are actually 32-bit formats but just omitting the unused bits from the name. \$\endgroup\$ – Maximus Minimus Jun 14 '18 at 15:22

Pixel format isn't specified by your desktop, it's just the format that SDL2 uses for pixels.

As @Maximus Minimus said, the 8 bits are unused, with 24 bits being 8 red, 8 green, 8 blue. This is 32 bits in total.

Look at: https://wiki.libsdl.org/SDL_PixelFormat and https://wiki.libsdl.org/SDL_PixelFormatEnum for more information.

Hope this helps.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.