diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-08-23 12:06:41 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-08-24 21:08:16 +0300 |
commit | 640fc369b474e395975e82471a1e4be291d23407 (patch) | |
tree | 877823a1caf7ac5803a8ee3512fd4038af50395b /src/graphics.cpp | |
parent | d80453b5cbf958084a21e624b1dcd2798f19659a (diff) | |
download | manaplus-640fc369b474e395975e82471a1e4be291d23407.tar.gz manaplus-640fc369b474e395975e82471a1e4be291d23407.tar.bz2 manaplus-640fc369b474e395975e82471a1e4be291d23407.tar.xz manaplus-640fc369b474e395975e82471a1e4be291d23407.zip |
fix images converting and drawing issues in SDL2 and OpenGL.
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r-- | src/graphics.cpp | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp index e08304b24..e0666a36a 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -55,6 +55,9 @@ Graphics::Graphics() : mWindow(nullptr), #ifdef USE_SDL2 mRenderer(nullptr), +#ifdef USE_OPENGL + mGLContext(nullptr), +#endif #endif mBpp(0), mAlpha(false), @@ -82,6 +85,20 @@ Graphics::Graphics() : Graphics::~Graphics() { _endDraw(); +#ifdef USE_SDL2 + if (mRenderer) + { + SDL_DestroyRenderer(mRenderer); + mRenderer = nullptr; + } +#ifdef USE_OPENGL + if (mGLContext) + { + SDL_GL_DeleteContext(mGLContext); + mGLContext = 0; + } +#endif +#endif } void Graphics::setSync(const bool sync) @@ -111,7 +128,7 @@ int Graphics::getOpenGLFlags() const #ifdef USE_OPENGL #ifdef USE_SDL2 - int displayFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_OPENGL; + int displayFlags = SDL_WINDOW_OPENGL; if (mFullscreen) displayFlags |= SDL_WINDOW_FULLSCREEN; #else @@ -136,12 +153,9 @@ int Graphics::getOpenGLFlags() const displayFlags |= SDL_NOFRAME; return displayFlags; - -#else // USE_OPENGL - +#else return 0; #endif // USE_OPENGL - } bool Graphics::setOpenGLMode() @@ -163,11 +177,13 @@ bool Graphics::setOpenGLMode() mRect.w = w1; mRect.h = h1; - mRenderer = graphicsManager.createRenderer(mWindow, 0); -#else + mGLContext = SDL_GL_CreateContext(mWindow); + +#else // USE_SDL2 + mRect.w = static_cast<uint16_t>(mWindow->w); mRect.h = static_cast<uint16_t>(mWindow->h); -#endif +#endif // USE_SDL2 #ifdef __APPLE__ if (mSync) @@ -217,9 +233,11 @@ bool Graphics::setOpenGLMode() OpenGLImageHelper::mTextureSize); } return videoInfo(); -#else +#else // USE_OPENGL + return false; -#endif +#endif // USE_OPENGL + } int Graphics::getSoftwareFlags() const |