diff options
-rw-r--r-- | src/graphics.cpp | 5 | ||||
-rw-r--r-- | src/graphicsmanager.cpp | 8 | ||||
-rw-r--r-- | src/graphicsmanager.h | 6 | ||||
-rw-r--r-- | src/sdl2graphics.cpp | 5 | ||||
-rw-r--r-- | src/sdlgraphics.cpp | 5 |
5 files changed, 25 insertions, 4 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp index 188ad85d6..387566013 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -141,8 +141,11 @@ bool Graphics::setOpenGLMode() { #ifdef USE_OPENGL SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - if (!(mWindow = SDL_SetVideoMode(mWidth, mHeight, mBpp, getOpenGLFlags()))) + if (!(mWindow = graphicsManager.createWindow(mWidth, mHeight, + mBpp, getOpenGLFlags()))) + { return false; + } #ifdef __APPLE__ if (mSync) diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp index c0ea92ba6..0d66dc3a7 100644 --- a/src/graphicsmanager.cpp +++ b/src/graphicsmanager.cpp @@ -139,7 +139,7 @@ int GraphicsManager::detectGraphics() logger->log1("enable opengl mode"); int textureSampler = 0; int compressTextures = 0; - SDL_SetVideoMode(100, 100, 0, SDL_ANYFORMAT | SDL_OPENGL); + createWindow(100, 100, 0, SDL_ANYFORMAT | SDL_OPENGL); initOpenGL(); logVersion(); @@ -379,6 +379,12 @@ bool GraphicsManager::getAllVideoModes(StringVect &modeList) } } +SDL_Window *GraphicsManager::createWindow(const int w, const int h, + const int bpp, const int flags) +{ + return SDL_SetVideoMode(w, h, bpp, flags); +} + #ifdef USE_OPENGL void GraphicsManager::updateExtensions() { diff --git a/src/graphicsmanager.h b/src/graphicsmanager.h index fbea60980..40e323c60 100644 --- a/src/graphicsmanager.h +++ b/src/graphicsmanager.h @@ -37,6 +37,8 @@ #endif +#include "sdlshared.h" + #include "utils/stringvector.h" #include <SDL_stdinc.h> @@ -50,6 +52,7 @@ class Graphics; class TestMain; struct FBOInfo; +struct SDL_Window; enum ScreenDensity { @@ -75,6 +78,9 @@ class GraphicsManager final void setVideoMode(); + SDL_Window *createWindow(const int w, const int h, + const int bpp, const int flags); + bool getAllVideoModes(StringVect &modeList); void detectPixelSize(); diff --git a/src/sdl2graphics.cpp b/src/sdl2graphics.cpp index d5e984700..99f022bcb 100644 --- a/src/sdl2graphics.cpp +++ b/src/sdl2graphics.cpp @@ -1138,8 +1138,11 @@ bool SDLGraphics::setVideoMode(const int w, const int h, const int bpp, { setMainFlags(w, h, bpp, fs, hwaccel, resize, noFrame); - if (!(mWindow = SDL_SetVideoMode(w, h, bpp, getSoftwareFlags()))) + if (!(mWindow = graphicsManager.createWindow(w, h, bpp, + getSoftwareFlags()))) + { return false; + } mRect.w = static_cast<uint16_t>(mWindow->w); mRect.h = static_cast<uint16_t>(mWindow->h); diff --git a/src/sdlgraphics.cpp b/src/sdlgraphics.cpp index 75cb7883d..6bc196cd9 100644 --- a/src/sdlgraphics.cpp +++ b/src/sdlgraphics.cpp @@ -1138,8 +1138,11 @@ bool SDLGraphics::setVideoMode(const int w, const int h, const int bpp, { setMainFlags(w, h, bpp, fs, hwaccel, resize, noFrame); - if (!(mWindow = SDL_SetVideoMode(w, h, bpp, getSoftwareFlags()))) + if (!(mWindow = graphicsManager.createWindow(w, h, bpp, + getSoftwareFlags()))) + { return false; + } mRect.w = static_cast<uint16_t>(mWindow->w); mRect.h = static_cast<uint16_t>(mWindow->h); |