From ed6689d4fcfd30a36cb01392bbd9705732cfac4a Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 28 Feb 2016 17:02:19 +0100 Subject: OPENGL: Do not allow direct access to Context::activePipeline. --- backends/graphics/opengl/framebuffer.cpp | 2 +- backends/graphics/opengl/opengl-graphics.cpp | 18 +++++++++--------- backends/graphics/opengl/opengl-sys.h | 7 +++++++ backends/graphics/opengl/texture.cpp | 10 +++++----- 4 files changed, 22 insertions(+), 15 deletions(-) (limited to 'backends/graphics') diff --git a/backends/graphics/opengl/framebuffer.cpp b/backends/graphics/opengl/framebuffer.cpp index 85245b683c..6775360e00 100644 --- a/backends/graphics/opengl/framebuffer.cpp +++ b/backends/graphics/opengl/framebuffer.cpp @@ -93,7 +93,7 @@ void Framebuffer::applyViewport() { } void Framebuffer::applyProjectionMatrix() { - g_context.activePipeline->setProjectionMatrix(_projectionMatrix); + g_context.getActivePipeline()->setProjectionMatrix(_projectionMatrix); } void Framebuffer::applyClearColor() { diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index a685f34bbf..6ede6a296c 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -396,11 +396,11 @@ void OpenGLGraphicsManager::updateScreen() { const GLfloat shakeOffset = _gameScreenShakeOffset * (GLfloat)_displayHeight / _gameScreen->getHeight(); // First step: Draw the (virtual) game screen. - g_context.activePipeline->drawTexture(_gameScreen->getGLTexture(), _displayX, _displayY + shakeOffset, _displayWidth, _displayHeight); + g_context.getActivePipeline()->drawTexture(_gameScreen->getGLTexture(), _displayX, _displayY + shakeOffset, _displayWidth, _displayHeight); // Second step: Draw the overlay if visible. if (_overlayVisible) { - g_context.activePipeline->drawTexture(_overlay->getGLTexture(), 0, 0, _outputScreenWidth, _outputScreenHeight); + g_context.getActivePipeline()->drawTexture(_overlay->getGLTexture(), 0, 0, _outputScreenWidth, _outputScreenHeight); } // Third step: Draw the cursor if visible. @@ -409,7 +409,7 @@ void OpenGLGraphicsManager::updateScreen() { // visible. const GLfloat cursorOffset = _overlayVisible ? 0 : shakeOffset; - g_context.activePipeline->drawTexture(_cursor->getGLTexture(), + g_context.getActivePipeline()->drawTexture(_cursor->getGLTexture(), _cursorDisplayX - _cursorHotspotXScaled, _cursorDisplayY - _cursorHotspotYScaled + cursorOffset, _cursorWidthScaled, _cursorHeightScaled); @@ -433,13 +433,13 @@ void OpenGLGraphicsManager::updateScreen() { } // Set the OSD transparency. - g_context.activePipeline->setColor(1.0f, 1.0f, 1.0f, _osdAlpha / 100.0f); + g_context.getActivePipeline()->setColor(1.0f, 1.0f, 1.0f, _osdAlpha / 100.0f); // Draw the OSD texture. - g_context.activePipeline->drawTexture(_osd->getGLTexture(), 0, 0, _outputScreenWidth, _outputScreenHeight); + g_context.getActivePipeline()->drawTexture(_osd->getGLTexture(), 0, 0, _outputScreenWidth, _outputScreenHeight); // Reset color. - g_context.activePipeline->setColor(1.0f, 1.0f, 1.0f, 1.0f); + g_context.getActivePipeline()->setColor(1.0f, 1.0f, 1.0f, 1.0f); } #endif @@ -865,7 +865,7 @@ void OpenGLGraphicsManager::notifyContextCreate(const Graphics::PixelFormat &def if (g_context.shadersSupported) { ShaderMan.notifyCreate(); - g_context.activePipeline->setShader(ShaderMan.query(ShaderManager::kDefault)); + g_context.getActivePipeline()->setShader(ShaderMan.query(ShaderManager::kDefault)); } #endif @@ -874,7 +874,7 @@ void OpenGLGraphicsManager::notifyContextCreate(const Graphics::PixelFormat &def GL_CALL(glDisable(GL_DEPTH_TEST)); GL_CALL(glDisable(GL_DITHER)); - g_context.activePipeline->setColor(1.0f, 1.0f, 1.0f, 1.0f); + g_context.getActivePipeline()->setColor(1.0f, 1.0f, 1.0f, 1.0f); GL_CALL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); @@ -887,7 +887,7 @@ void OpenGLGraphicsManager::notifyContextCreate(const Graphics::PixelFormat &def // Setup scissor state accordingly. _backBuffer.enableScissorTest(!_overlayVisible); - g_context.activePipeline->setFramebuffer(&_backBuffer); + g_context.getActivePipeline()->setFramebuffer(&_backBuffer); // Clear the whole screen for the first three frames to assure any // leftovers are cleared. diff --git a/backends/graphics/opengl/opengl-sys.h b/backends/graphics/opengl/opengl-sys.h index 723e28fa17..4495128f32 100644 --- a/backends/graphics/opengl/opengl-sys.h +++ b/backends/graphics/opengl/opengl-sys.h @@ -129,9 +129,11 @@ struct Context { // programmable pipelines in the same fashion. // +private: /** Currently active rendering pipeline. */ Pipeline *activePipeline; +public: /** * Set new pipeline. * @@ -141,6 +143,11 @@ struct Context { * @return Formerly active pipeline. */ Pipeline *setPipeline(Pipeline *pipeline); + + /** + * Query the currently active rendering pipeline. + */ + Pipeline *getActivePipeline() const { return activePipeline; } }; /** diff --git a/backends/graphics/opengl/texture.cpp b/backends/graphics/opengl/texture.cpp index 8b38f85e9f..8746527d5b 100644 --- a/backends/graphics/opengl/texture.cpp +++ b/backends/graphics/opengl/texture.cpp @@ -615,10 +615,10 @@ void TextureCLUT8GPU::updateGLTexture() { void TextureCLUT8GPU::lookUpColors() { // Save old state. - Framebuffer *oldFramebuffer = g_context.activePipeline->setFramebuffer(_target); + Framebuffer *oldFramebuffer = g_context.getActivePipeline()->setFramebuffer(_target); Shader *lookUpShader = ShaderMan.query(ShaderManager::kCLUT8LookUp); - Shader *oldShader = g_context.activePipeline->setShader(lookUpShader); + Shader *oldShader = g_context.getActivePipeline()->setShader(lookUpShader); lookUpShader->setUniformI(_paletteLocation, 1); // Set the palette texture. @@ -627,11 +627,11 @@ void TextureCLUT8GPU::lookUpColors() { GL_CALL(glActiveTexture(GL_TEXTURE0)); // Do color look up. - g_context.activePipeline->drawTexture(_clut8Texture, _clut8Vertices); + g_context.getActivePipeline()->drawTexture(_clut8Texture, _clut8Vertices); // Restore old state. - g_context.activePipeline->setShader(oldShader); - g_context.activePipeline->setFramebuffer(oldFramebuffer); + g_context.getActivePipeline()->setShader(oldShader); + g_context.getActivePipeline()->setFramebuffer(oldFramebuffer); } #endif // !USE_FORCED_GLES -- cgit v1.2.3