aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/opengl
diff options
context:
space:
mode:
authorJohannes Schickel2015-12-10 16:42:56 +0100
committerJohannes Schickel2016-03-16 20:29:24 +0100
commite5e234b864e75862a2de72ee6c3b8bda47f41c23 (patch)
treec46336ce94d7f26a51ab90e1b1b3427eeb05fa86 /backends/graphics/opengl
parentb5b88ffb229663a648de332994c1008bb65a87f7 (diff)
downloadscummvm-rg350-e5e234b864e75862a2de72ee6c3b8bda47f41c23.tar.gz
scummvm-rg350-e5e234b864e75862a2de72ee6c3b8bda47f41c23.tar.bz2
scummvm-rg350-e5e234b864e75862a2de72ee6c3b8bda47f41c23.zip
OPENGL: Refactor GL extension handling slightly.
Diffstat (limited to 'backends/graphics/opengl')
-rw-r--r--backends/graphics/opengl/extensions.cpp13
-rw-r--r--backends/graphics/opengl/extensions.h23
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp1
-rw-r--r--backends/graphics/opengl/opengl-graphics.h6
-rw-r--r--backends/graphics/opengl/texture.cpp2
5 files changed, 35 insertions, 10 deletions
diff --git a/backends/graphics/opengl/extensions.cpp b/backends/graphics/opengl/extensions.cpp
index 4482ef82b5..c76f8d7ca6 100644
--- a/backends/graphics/opengl/extensions.cpp
+++ b/backends/graphics/opengl/extensions.cpp
@@ -22,25 +22,30 @@
#include "backends/graphics/opengl/extensions.h"
#include "backends/graphics/opengl/opengl-sys.h"
+#include "backends/graphics/opengl/opengl-graphics.h"
#include "common/tokenizer.h"
namespace OpenGL {
-bool g_extNPOTSupported = false;
+void ExtensionsDesc::reset() {
+ NPOTSupported = false;
+}
+
+ExtensionsDesc g_extensions;
-void initializeGLExtensions() {
+void OpenGLGraphicsManager::initializeGLExtensions() {
const char *extString = (const char *)glGetString(GL_EXTENSIONS);
// Initialize default state.
- g_extNPOTSupported = false;
+ g_extensions.reset();
Common::StringTokenizer tokenizer(extString, " ");
while (!tokenizer.empty()) {
Common::String token = tokenizer.nextToken();
if (token == "GL_ARB_texture_non_power_of_two") {
- g_extNPOTSupported = true;
+ g_extensions.NPOTSupported = true;
}
}
}
diff --git a/backends/graphics/opengl/extensions.h b/backends/graphics/opengl/extensions.h
index 87452429e2..5b9eb538d9 100644
--- a/backends/graphics/opengl/extensions.h
+++ b/backends/graphics/opengl/extensions.h
@@ -26,15 +26,28 @@
namespace OpenGL {
/**
- * Checks for availability of extensions we want to use and initializes them
- * when available.
+ * Description structure of all available extensions.
+ *
+ * This includes information whether extensions we are interested in is
+ * available or not. If extensions we are interested in add additional
+ * functions, we keep function pointers around in here too.
*/
-void initializeGLExtensions();
+struct ExtensionsDesc {
+ /**
+ * Reset extension state.
+ *
+ * This marks all extensions as unavailable.
+ */
+ void reset();
+
+ /** Whether GL_ARB_texture_non_power_of_two is available or not. */
+ bool NPOTSupported;
+};
/**
- * Whether non power of two textures are supported
+ * Description of all available extensions.
*/
-extern bool g_extNPOTSupported;
+extern ExtensionsDesc g_extensions;
} // End of namespace OpenGL
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index ac6d41d47d..d738f31a37 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -58,6 +58,7 @@ OpenGLGraphicsManager::OpenGLGraphicsManager()
#endif
{
memset(_gamePalette, 0, sizeof(_gamePalette));
+ g_extensions.reset();
}
OpenGLGraphicsManager::~OpenGLGraphicsManager() {
diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h
index 9578839383..2a03b878ce 100644
--- a/backends/graphics/opengl/opengl-graphics.h
+++ b/backends/graphics/opengl/opengl-graphics.h
@@ -281,6 +281,12 @@ private:
//
/**
+ * Checks for availability of extensions we want to use and initializes them
+ * when available.
+ */
+ void initializeGLExtensions();
+
+ /**
* Try to determine the internal parameters for a given pixel format.
*
* @return true when the format can be used, false otherwise.
diff --git a/backends/graphics/opengl/texture.cpp b/backends/graphics/opengl/texture.cpp
index 7b0b22d630..36fe5ab744 100644
--- a/backends/graphics/opengl/texture.cpp
+++ b/backends/graphics/opengl/texture.cpp
@@ -105,7 +105,7 @@ void Texture::enableLinearFiltering(bool enable) {
void Texture::allocate(uint width, uint height) {
uint texWidth = width, texHeight = height;
- if (!g_extNPOTSupported) {
+ if (!g_extensions.NPOTSupported) {
texWidth = nextHigher2(texWidth);
texHeight = nextHigher2(texHeight);
}