Change SDL Background

Is there a way to change the color of an empty SDL window to white instead of black? I do not want to change the default settings. I am just trying to change it for this particular program that I am writing. I do not want to use the image file, but if necessary, I will.

I don't know if that matters, but I'm using SDL_SetVideoMode()

My code is very simple:

 if (SDL_Init(SDL_INIT_EVERYTHING) == -1) return 1; SDL_Surface * screen = NULL; screen = SDL_SetVideoMode(width, height, bpp, SDL_SWSURFACE); SDL_FillRect(screen, NULL, 0xFFFFFF); SDL_Delay(3000); 
+4
source share
4 answers

Get the surface from your window with surf = SDL_SetVideoMode(...) and then do

 SDL_FillRect(surf, NULL, 0xFFFFFF); // 0xFFFFFF = white in RGB, NULL = full window SDL_Flip(surf); 
+4
source

You need to call SDL_Flip so that your changes are displayed.

+5
source

You can use SDL_FillRect to fill the screen / surface with the desired color.

+3
source

You need to call SDL_UpdateRect after SDL_FillRect.

+3
source

All Articles