diff options
Diffstat (limited to 'backends/graphics/opengl')
-rw-r--r-- | backends/graphics/opengl/context.cpp | 25 | ||||
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.cpp | 6 | ||||
-rw-r--r-- | backends/graphics/opengl/opengl-graphics.h | 22 | ||||
-rw-r--r-- | backends/graphics/opengl/opengl-sys.h | 5 |
4 files changed, 31 insertions, 27 deletions
diff --git a/backends/graphics/opengl/context.cpp b/backends/graphics/opengl/context.cpp index d1776f851d..0077cc2746 100644 --- a/backends/graphics/opengl/context.cpp +++ b/backends/graphics/opengl/context.cpp @@ -27,24 +27,32 @@ namespace OpenGL { -void Context::reset() { - ready = false; - type = kContextGL; +void Context::reset(bool full) { + if (full) { + // GLES supports least features, thus we initialize the context type + // to this on full reset. + type = kContextGLES; + } + NPOTSupported = false; } Context g_context; -void OpenGLGraphicsManager::initializeGLContext(ContextType type) { - // Initialize default state. - g_context.reset(); - +void OpenGLGraphicsManager::setContextType(ContextType type) { #if USE_FORCED_GL type = kContextGL; #elif USE_FORCED_GLES type = kContextGLES; #endif + g_context.type = type; +} + +void OpenGLGraphicsManager::initializeGLContext() { + // Initialize default state. + g_context.reset(); + // Load all functions. // We use horrible trickery to silence C++ compilers. // See backends/plugins/sdl/sdl-provider.cpp for more information. @@ -72,9 +80,6 @@ void OpenGLGraphicsManager::initializeGLContext(ContextType type) { g_context.NPOTSupported = true; } } - - g_context.ready = true; - g_context.type = type; } } // End of namespace OpenGL diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 8db5f6a934..78c6b2aff1 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -56,7 +56,7 @@ OpenGLGraphicsManager::OpenGLGraphicsManager() #endif { memset(_gamePalette, 0, sizeof(_gamePalette)); - g_context.reset(); + g_context.reset(true); } OpenGLGraphicsManager::~OpenGLGraphicsManager() { @@ -840,9 +840,9 @@ void OpenGLGraphicsManager::setActualScreenSize(uint width, uint height) { ++_screenChangeID; } -void OpenGLGraphicsManager::notifyContextCreate(const Graphics::PixelFormat &defaultFormat, const Graphics::PixelFormat &defaultFormatAlpha, ContextType type) { +void OpenGLGraphicsManager::notifyContextCreate(const Graphics::PixelFormat &defaultFormat, const Graphics::PixelFormat &defaultFormatAlpha) { // Initialize context for use. - initializeGLContext(type); + initializeGLContext(); // Disable 3D properties. GL_CALL(glDisable(GL_CULL_FACE)); diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index 5f0436c0b5..5a2b1bb373 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -117,11 +117,6 @@ public: protected: /** - * Whether an OpenGL (context) is active. - */ - bool isInitialized() const { return g_context.ready; } - - /** * Whether an GLES context is active. */ bool isGLESContext() const { return g_context.type == kContextGLES; } @@ -136,6 +131,16 @@ protected: void setActualScreenSize(uint width, uint height); /** + * Sets the OpenGL (ES) type the graphics manager shall work with. + * + * This needs to be called at least once (and before ever calling + * notifyContextCreate). + * + * @param type Type of the OpenGL (ES) contexts to be created. + */ + void setContextType(ContextType type); + + /** * Notify the manager of a OpenGL context change. This should be the first * thing to call after you created an OpenGL (ES) context! * @@ -143,9 +148,8 @@ protected: * (this is used for the CLUT8 game screens). * @param defaultFormatAlpha The new default format with an alpha channel * (this is used for the overlay and cursor). - * @param type Type of the created context. */ - void notifyContextCreate(const Graphics::PixelFormat &defaultFormat, const Graphics::PixelFormat &defaultFormatAlpha, ContextType type); + void notifyContextCreate(const Graphics::PixelFormat &defaultFormat, const Graphics::PixelFormat &defaultFormatAlpha); /** * Notify the manager that the OpenGL context is about to be destroyed. @@ -293,10 +297,8 @@ private: /** * Initialize the active context for use. - * - * @param type Type of the context to initialize. */ - void initializeGLContext(ContextType type); + void initializeGLContext(); protected: /** diff --git a/backends/graphics/opengl/opengl-sys.h b/backends/graphics/opengl/opengl-sys.h index 550dbb44c5..250357f92a 100644 --- a/backends/graphics/opengl/opengl-sys.h +++ b/backends/graphics/opengl/opengl-sys.h @@ -76,9 +76,6 @@ enum ContextType { * Description structure of the OpenGL (ES) context. */ struct Context { - /** Whether the context is properly initalized or not. */ - bool ready; - /** The type of the active context. */ ContextType type; @@ -87,7 +84,7 @@ struct Context { * * This marks all extensions as unavailable. */ - void reset(); + void reset(bool full = false); /** Whether GL_ARB_texture_non_power_of_two is available or not. */ bool NPOTSupported; |