1
0
Fork 0

Codechange: [SDL2] Split away CreateMainWindow from CreateMainSurface

This makes the code a bit more readable, as both intentions are
more clear, and there is less nesting in the main function.
pull/8622/head
Patric Stout 2021-01-24 11:54:36 +01:00 committed by Patric Stout
parent 8c37e5c526
commit 19345908cb
2 changed files with 49 additions and 43 deletions

View File

@ -280,15 +280,10 @@ static uint FindStartupDisplay(uint startup_display)
return 0;
}
bool VideoDriver_SDL::CreateMainSurface(uint w, uint h, bool resize)
bool VideoDriver_SDL::CreateMainWindow(uint w, uint h)
{
int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
if (_sdl_window != nullptr) return true;
GetAvailableVideoMode(&w, &h);
DEBUG(driver, 1, "SDL2: using mode %ux%ux%d", w, h, bpp);
if (_sdl_window == nullptr) {
Uint32 flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE;
if (_fullscreen) {
@ -328,8 +323,18 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h, bool resize)
SDL_FreeSurface(icon);
}
}
}
return true;
}
bool VideoDriver_SDL::CreateMainSurface(uint w, uint h, bool resize)
{
int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
GetAvailableVideoMode(&w, &h);
DEBUG(driver, 1, "SDL2: using mode %ux%ux%d", w, h, bpp);
if (!this->CreateMainWindow(w, h)) return false;
if (resize) SDL_SetWindowSize(_sdl_window, w, h);
_sdl_real_surface = SDL_GetWindowSurface(_sdl_window);

View File

@ -49,6 +49,7 @@ private:
void LoopOnce();
void MainLoopCleanup();
bool CreateMainSurface(uint w, uint h, bool resize);
bool CreateMainWindow(uint w, uint h);
#ifdef __EMSCRIPTEN__
/* Convert a constant pointer back to a non-constant pointer to a member function. */