summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-23 12:06:41 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-24 21:08:16 +0300
commit640fc369b474e395975e82471a1e4be291d23407 (patch)
tree877823a1caf7ac5803a8ee3512fd4038af50395b /src
parentd80453b5cbf958084a21e624b1dcd2798f19659a (diff)
downloadManaVerse-640fc369b474e395975e82471a1e4be291d23407.tar.gz
ManaVerse-640fc369b474e395975e82471a1e4be291d23407.tar.bz2
ManaVerse-640fc369b474e395975e82471a1e4be291d23407.tar.xz
ManaVerse-640fc369b474e395975e82471a1e4be291d23407.zip
fix images converting and drawing issues in SDL2 and OpenGL.
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp2
-rw-r--r--src/graphics.cpp38
-rw-r--r--src/graphics.h4
-rw-r--r--src/normalopenglgraphics.cpp2
-rw-r--r--src/resources/openglimagehelper.cpp5
5 files changed, 38 insertions, 13 deletions
diff --git a/src/client.cpp b/src/client.cpp
index aeee05c1f..090591ff4 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1102,6 +1102,8 @@ int Client::gameExec()
lastTickTime = tick_time;
#ifdef USE_SDL2
+ if (gui)
+ gui->draw();
mainGraphics->updateScreen();
#else
// Update the screen when application is active, delay otherwise.
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
diff --git a/src/graphics.h b/src/graphics.h
index a90e1d0e7..2715ceae2 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -393,8 +393,12 @@ class Graphics : public gcn::Graphics
bool videoInfo();
SDL_Window *mWindow;
+
#ifdef USE_SDL2
SDL_Renderer *mRenderer;
+#ifdef USE_OPENGL
+ SDL_GLContext mGLContext;
+#endif
#endif
int mBpp;
bool mAlpha;
diff --git a/src/normalopenglgraphics.cpp b/src/normalopenglgraphics.cpp
index 089077224..a4b9e8c07 100644
--- a/src/normalopenglgraphics.cpp
+++ b/src/normalopenglgraphics.cpp
@@ -1093,8 +1093,6 @@ void NormalOpenGLGraphics::_beginDraw()
#endif
#endif
-// glScalef(0.5f, 0.5f, 0.5f);
-
pushClipArea(gcn::Rectangle(0, 0, w, h));
}
diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp
index 6aed74113..67af6655f 100644
--- a/src/resources/openglimagehelper.cpp
+++ b/src/resources/openglimagehelper.cpp
@@ -152,7 +152,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
}
#ifdef USE_SDL2
- SDL_SetSurfaceAlphaMod(tmpImage, 255);
+ SDL_SetSurfaceAlphaMod(tmpImage, SDL_ALPHA_OPAQUE);
#else
// Make sure the alpha channel is not used, but copied to destination
SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
@@ -180,6 +180,9 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage,
|| amask != tmpImage->format->Amask)
{
oldImage = tmpImage;
+#ifdef USE_SDL2
+ SDL_SetSurfaceBlendMode (oldImage, SDL_BLENDMODE_NONE);
+#endif
tmpImage = SDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
32, rmask, gmask, bmask, amask);