summaryrefslogtreecommitdiff
path: root/src/render/graphics.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-06-23 23:18:36 +0300
committerAndrei Karas <akaras@inbox.ru>2014-06-24 00:38:16 +0300
commit34279cbb4ea6506c3d64a62e20cd97643999ce61 (patch)
tree834f737ba88af9b718ab2097e77f9953afcaa586 /src/render/graphics.cpp
parenta1521294fda5b8b5bba3e7b512573bfcbc4c7fbe (diff)
downloadmv-34279cbb4ea6506c3d64a62e20cd97643999ce61.tar.gz
mv-34279cbb4ea6506c3d64a62e20cd97643999ce61.tar.bz2
mv-34279cbb4ea6506c3d64a62e20cd97643999ce61.tar.xz
mv-34279cbb4ea6506c3d64a62e20cd97643999ce61.zip
Add manual OpenGL context creation.
For SDL2 set attributes for context version. For SDL1.2 in X11 create own context. For SDL1.2 and other platforms not implimented for now. Also try fallback if need to older context versions.
Diffstat (limited to 'src/render/graphics.cpp')
-rw-r--r--src/render/graphics.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp
index 5bb90e753..5cb45e8ca 100644
--- a/src/render/graphics.cpp
+++ b/src/render/graphics.cpp
@@ -71,6 +71,8 @@
#include "graphicsmanager.h"
#include "logger.h"
+#include "render/mglxinit.h"
+
#include "resources/imagehelper.h"
#include "resources/openglimagehelper.h"
@@ -99,10 +101,10 @@ Graphics::Graphics() :
mWindow(nullptr),
#ifdef USE_SDL2
mRenderer(nullptr),
+#endif
#ifdef USE_OPENGL
mGLContext(nullptr),
#endif
-#endif
mBpp(0),
mAlpha(false),
mFullscreen(false),
@@ -252,11 +254,15 @@ bool Graphics::setOpenGLMode()
mActualWidth, mActualHeight,
mBpp, getOpenGLFlags())))
{
+ logger->log("Window/context creation failed");
mRect.w = 0;
mRect.h = 0;
return false;
}
+#if defined(USE_OPENGL) && defined(USE_X11)
+ Glx::initFunctions();
+#endif
#ifdef USE_SDL2
int w1 = 0;
int h1 = 0;
@@ -264,10 +270,10 @@ bool Graphics::setOpenGLMode()
mRect.w = static_cast<int32_t>(w1 / mScale);
mRect.h = static_cast<int32_t>(h1 / mScale);
- mGLContext = SDL_GL_CreateContext(mWindow);
-
+ createGLContext();
#else // USE_SDL2
+ createGLContext();
mRect.w = static_cast<uint16_t>(mWindow->w / mScale);
mRect.h = static_cast<uint16_t>(mWindow->h / mScale);
@@ -353,6 +359,14 @@ int Graphics::getSoftwareFlags() const
return displayFlags;
}
+#ifdef USE_OPENGL
+void Graphics::createGLContext()
+{
+#ifdef USE_SDL2
+ mGLContext = SDL_GL_CreateContext(mWindow);
+#endif
+}
+#endif
void Graphics::updateMemoryInfo()
{