From e8ff5419a08bf5eae639bbf6bdebe9692a0b3d53 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 7 Jun 2014 23:21:18 +0300 Subject: Fallback to safe OpenGL mode if OpenGL version is lower than 2.0. --- src/graphicsmanager.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/graphicsmanager.cpp') 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 -- cgit v1.2.3-70-g09d2