summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-09-02 02:11:07 +0300
committerAndrei Karas <akaras@inbox.ru>2013-09-02 02:11:07 +0300
commit7c251f07c2b3fdfe99be11ac59aa813b4f3437bb (patch)
tree8427406f76bc18e711f2be258a0bbf35a844021f /src/render
parent7dd01a95a1e7522cd3cb3bdda2e96a75770e2e55 (diff)
downloadplus-7c251f07c2b3fdfe99be11ac59aa813b4f3437bb.tar.gz
plus-7c251f07c2b3fdfe99be11ac59aa813b4f3437bb.tar.bz2
plus-7c251f07c2b3fdfe99be11ac59aa813b4f3437bb.tar.xz
plus-7c251f07c2b3fdfe99be11ac59aa813b4f3437bb.zip
improve render mode validation after reading from config.
Diffstat (limited to 'src/render')
-rw-r--r--src/render/renderers.cpp36
-rw-r--r--src/render/renderers.h2
2 files changed, 31 insertions, 7 deletions
diff --git a/src/render/renderers.cpp b/src/render/renderers.cpp
index 97364f54a..dcabd0fbf 100644
--- a/src/render/renderers.cpp
+++ b/src/render/renderers.cpp
@@ -20,19 +20,43 @@
#include "render/renderers.h"
-RenderType intToRenderType(const int mode)
+static RenderType getDefault()
{
- if (mode < 0 || mode > RENDER_LAST)
- {
#ifdef USE_OPENGL
#ifdef ANDROID
- return RENDER_GLES_OPENGL;
+ return RENDER_GLES_OPENGL;
#else
- return RENDER_NORMAL_OPENGL;
+ return RENDER_NORMAL_OPENGL;
#endif
#else
- return RENDER_SOFTWARE;
+ return RENDER_SOFTWARE;
+#endif
+}
+
+RenderType intToRenderType(const int mode)
+{
+ if (mode < 0 || mode >= RENDER_LAST)
+ return getDefault();
+
+ if (mode != RENDER_SOFTWARE
+#if defined(USE_OPENGL) && defined(ANDROID) && defined(USE_SDL2)
+ && mode != RENDER_GLES_OPENGL && mode != RENDER_SDL2_DEFAULT)
+#elif defined(USE_OPENGL) && defined(ANDROID) && !defined(USE_SDL2)
+ && mode != RENDER_GLES_OPENGL)
+#elif defined(USE_OPENGL) && !defined(ANDROID) && defined(USE_SDL2)
+ && mode != RENDER_NORMAL_OPENGL && mode != RENDER_SAFE_OPENGL
+ && mode != RENDER_GLES_OPENGL && mode != RENDER_SDL2_DEFAULT)
+#elif !defined(USE_OPENGL) && defined(USE_SDL2)
+ && mode != RENDER_SDL2_DEFAULT)
+#elif !defined(USE_OPENGL) && !defined(USE_SDL2)
+ )
+#elif defined(USE_OPENGL) && !defined(ANDROID) && !defined(USE_SDL2)
+ && mode != RENDER_NORMAL_OPENGL && mode != RENDER_SAFE_OPENGL
+ && mode != RENDER_GLES_OPENGL)
#endif
+ {
+ return getDefault();
}
+
return static_cast<RenderType>(mode);
}
diff --git a/src/render/renderers.h b/src/render/renderers.h
index 2a6af27d2..c49ca81c4 100644
--- a/src/render/renderers.h
+++ b/src/render/renderers.h
@@ -31,7 +31,7 @@ enum RenderType
RENDER_GLES_OPENGL = 3,
RENDER_SDL2_DEFAULT = 4,
RENDER_NULL = 5,
- RENDER_LAST
+ RENDER_LAST,
};
RenderType intToRenderType(const int mode);