OPENGL: Only allow Pipeline to switch active Framebuffers.
This commit is contained in:
parent
ed6689d4fc
commit
bec2088d6c
2 changed files with 42 additions and 25 deletions
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue