summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-06-07 23:21:18 +0300
committerAndrei Karas <akaras@inbox.ru>2014-06-07 23:21:18 +0300
commite8ff5419a08bf5eae639bbf6bdebe9692a0b3d53 (patch)
tree976e8b87c81a6929e5dfe2a8e87cc4b04c590022
parent5f478df06f4c04bdef94874860a1b40e8d0d62fe (diff)
downloadManaVerse-e8ff5419a08bf5eae639bbf6bdebe9692a0b3d53.tar.gz
ManaVerse-e8ff5419a08bf5eae639bbf6bdebe9692a0b3d53.tar.bz2
ManaVerse-e8ff5419a08bf5eae639bbf6bdebe9692a0b3d53.tar.xz
ManaVerse-e8ff5419a08bf5eae639bbf6bdebe9692a0b3d53.zip
Fallback to safe OpenGL mode if OpenGL version is lower than 2.0.
-rw-r--r--src/client.cpp7
-rw-r--r--src/graphicsmanager.cpp24
-rw-r--r--src/graphicsmanager.h2
3 files changed, 27 insertions, 6 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 12d0b82a3..8ddb5dcdd 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -627,12 +627,7 @@ void Client::gameClear()
if (logger)
logger->log1("Quitting3");
- delete2(mainGraphics);
-
- if (imageHelper != surfaceImageHelper)
- delete surfaceImageHelper;
- surfaceImageHelper = nullptr;
- delete2(imageHelper);
+ graphicsManager.deleteRenderers();
if (logger)
logger->log1("Quitting4");
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 25c083124..5cdda823f 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -62,6 +62,7 @@
#include "resources/surfaceimagehelper.h"
#endif
+#include "utils/delete2.h"
#include "utils/sdlhelper.h"
#include "utils/stringutils.h"
@@ -356,6 +357,15 @@ void GraphicsManager::createRenderers()
#endif // USE_OPENGL
}
+void GraphicsManager::deleteRenderers()
+{
+ delete2(mainGraphics);
+ if (imageHelper != surfaceImageHelper)
+ delete surfaceImageHelper;
+ surfaceImageHelper = nullptr;
+ delete2(imageHelper);
+}
+
void GraphicsManager::setVideoMode()
{
const int bpp = 0;
@@ -439,6 +449,20 @@ void GraphicsManager::initGraphics()
createRenderers();
detectPixelSize();
setVideoMode();
+#ifdef USE_OPENGL
+ if (openGLMode == RENDER_NORMAL_OPENGL || openGLMode == RENDER_GLES_OPENGL)
+ {
+ if (!checkGLVersion(2, 0))
+ {
+ logger->log("Fallback to safe OpenGL mode");
+ openGLMode = RENDER_SAFE_OPENGL;
+ deleteRenderers();
+ createRenderers();
+ detectPixelSize();
+ setVideoMode();
+ }
+ }
+#endif
}
#ifdef USE_SDL2
diff --git a/src/graphicsmanager.h b/src/graphicsmanager.h
index b0d6e9c9f..963e8dbb7 100644
--- a/src/graphicsmanager.h
+++ b/src/graphicsmanager.h
@@ -78,6 +78,8 @@ class GraphicsManager final
void createRenderers();
+ void deleteRenderers();
+
void initGraphics();
static void setVideoMode();