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.
This commit is contained in:

committed by
Patric Stout

parent
8c37e5c526
commit
19345908cb
@@ -280,15 +280,10 @@ static uint FindStartupDisplay(uint startup_display)
|
|||||||
return 0;
|
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;
|
Uint32 flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE;
|
||||||
|
|
||||||
if (_fullscreen) {
|
if (_fullscreen) {
|
||||||
@@ -328,8 +323,18 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h, bool resize)
|
|||||||
SDL_FreeSurface(icon);
|
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);
|
if (resize) SDL_SetWindowSize(_sdl_window, w, h);
|
||||||
|
|
||||||
_sdl_real_surface = SDL_GetWindowSurface(_sdl_window);
|
_sdl_real_surface = SDL_GetWindowSurface(_sdl_window);
|
||||||
|
@@ -49,6 +49,7 @@ private:
|
|||||||
void LoopOnce();
|
void LoopOnce();
|
||||||
void MainLoopCleanup();
|
void MainLoopCleanup();
|
||||||
bool CreateMainSurface(uint w, uint h, bool resize);
|
bool CreateMainSurface(uint w, uint h, bool resize);
|
||||||
|
bool CreateMainWindow(uint w, uint h);
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
/* Convert a constant pointer back to a non-constant pointer to a member function. */
|
/* Convert a constant pointer back to a non-constant pointer to a member function. */
|
||||||
|
Reference in New Issue
Block a user