diff options
author | Johannes Schickel | 2016-02-28 17:10:02 +0100 |
---|---|---|
committer | Johannes Schickel | 2016-03-16 20:29:30 +0100 |
commit | bec2088d6c312d15e4c3377b5afbcb5a6fb0a84e (patch) | |
tree | 1957fe58d8facdd702e4e49a5fdbacb4c65069f8 /backends | |
parent | ed6689d4fcfd30a36cb01392bbd9705732cfac4a (diff) | |
download | scummvm-rg350-bec2088d6c312d15e4c3377b5afbcb5a6fb0a84e.tar.gz scummvm-rg350-bec2088d6c312d15e4c3377b5afbcb5a6fb0a84e.tar.bz2 scummvm-rg350-bec2088d6c312d15e4c3377b5afbcb5a6fb0a84e.zip |
OPENGL: Only allow Pipeline to switch active Framebuffers.
Diffstat (limited to 'backends')
-rw-r--r-- | backends/graphics/opengl/framebuffer.cpp | 12 | ||||
-rw-r--r-- | backends/graphics/opengl/framebuffer.h | 55 |
2 files changed, 42 insertions, 25 deletions
diff --git a/backends/graphics/opengl/framebuffer.cpp b/backends/graphics/opengl/framebuffer.cpp index 6775360e00..f3332cb469 100644 --- a/backends/graphics/opengl/framebuffer.cpp +++ b/backends/graphics/opengl/framebuffer.cpp @@ -40,10 +40,14 @@ void Framebuffer::activate() { applyBlendState(); applyScissorTestState(); applyScissorBox(); + + activateInternal(); } void Framebuffer::deactivate() { _isActive = false; + + deactivateInternal(); } void Framebuffer::setClearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { @@ -124,9 +128,7 @@ void Framebuffer::applyScissorBox() { // Backbuffer implementation // -void Backbuffer::activate() { - Framebuffer::activate(); - +void Backbuffer::activateInternal() { #if !USE_FORCED_GLES if (g_context.framebufferObjectSupported) { GL_CALL(glBindFramebuffer(GL_FRAMEBUFFER, 0)); @@ -183,9 +185,7 @@ TextureTarget::~TextureTarget() { GL_CALL_SAFE(glDeleteFramebuffers, (1, &_glFBO)); } -void TextureTarget::activate() { - Framebuffer::activate(); - +void TextureTarget::activateInternal() { // Allocate framebuffer object if necessary. if (!_glFBO) { GL_CALL(glGenFramebuffers(1, &_glFBO)); diff --git a/backends/graphics/opengl/framebuffer.h b/backends/graphics/opengl/framebuffer.h index 467c00e5da..c44c98ddc4 100644 --- a/backends/graphics/opengl/framebuffer.h +++ b/backends/graphics/opengl/framebuffer.h @@ -31,25 +31,12 @@ namespace OpenGL { * Object describing a framebuffer OpenGL can render to. */ class Framebuffer { + friend class Pipeline; public: Framebuffer(); virtual ~Framebuffer() {}; - /** - * Activate framebuffer. - * - * This is supposed to set all state associated with the framebuffer. - */ - virtual void activate() = 0; - - /** - * Deactivate framebuffer. - * - * This is supposed to make any cleanup required when unbinding the - * framebuffer. - */ - virtual void deactivate(); - +public: /** * Set the clear color of the framebuffer. */ @@ -82,6 +69,33 @@ protected: GLfloat _projectionMatrix[4*4]; void applyProjectionMatrix(); + + /** + * Activate framebuffer. + * + * This is supposed to set all state associated with the framebuffer. + */ + virtual void activateInternal() = 0; + + /** + * Deactivate framebuffer. + * + * This is supposed to make any cleanup required when unbinding the + * framebuffer. + */ + virtual void deactivateInternal() {} + +private: + /** + * Accessor to activate framebuffer for pipeline. + */ + void activate(); + + /** + * Accessor to deactivate framebuffer from pipeline. + */ + void deactivate(); + private: bool _isActive; @@ -103,12 +117,13 @@ private: */ class Backbuffer : public Framebuffer { public: - virtual void activate(); - /** * Set the dimensions (a.k.a. size) of the back buffer. */ void setDimensions(uint width, uint height); + +protected: + virtual void activateInternal(); }; #if !USE_FORCED_GLES @@ -125,8 +140,6 @@ public: TextureTarget(); virtual ~TextureTarget(); - virtual void activate(); - /** * Notify that the GL context is about to be destroyed. */ @@ -146,6 +159,10 @@ public: * Query pointer to underlying GL texture. */ GLTexture *getTexture() const { return _texture; } + +protected: + virtual void activateInternal(); + private: GLTexture *_texture; GLuint _glFBO; |