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();
|
applyBlendState();
|
||||||
applyScissorTestState();
|
applyScissorTestState();
|
||||||
applyScissorBox();
|
applyScissorBox();
|
||||||
|
|
||||||
|
activateInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Framebuffer::deactivate() {
|
void Framebuffer::deactivate() {
|
||||||
_isActive = false;
|
_isActive = false;
|
||||||
|
|
||||||
|
deactivateInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Framebuffer::setClearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
|
void Framebuffer::setClearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
|
||||||
|
@ -124,9 +128,7 @@ void Framebuffer::applyScissorBox() {
|
||||||
// Backbuffer implementation
|
// Backbuffer implementation
|
||||||
//
|
//
|
||||||
|
|
||||||
void Backbuffer::activate() {
|
void Backbuffer::activateInternal() {
|
||||||
Framebuffer::activate();
|
|
||||||
|
|
||||||
#if !USE_FORCED_GLES
|
#if !USE_FORCED_GLES
|
||||||
if (g_context.framebufferObjectSupported) {
|
if (g_context.framebufferObjectSupported) {
|
||||||
GL_CALL(glBindFramebuffer(GL_FRAMEBUFFER, 0));
|
GL_CALL(glBindFramebuffer(GL_FRAMEBUFFER, 0));
|
||||||
|
@ -183,9 +185,7 @@ TextureTarget::~TextureTarget() {
|
||||||
GL_CALL_SAFE(glDeleteFramebuffers, (1, &_glFBO));
|
GL_CALL_SAFE(glDeleteFramebuffers, (1, &_glFBO));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureTarget::activate() {
|
void TextureTarget::activateInternal() {
|
||||||
Framebuffer::activate();
|
|
||||||
|
|
||||||
// Allocate framebuffer object if necessary.
|
// Allocate framebuffer object if necessary.
|
||||||
if (!_glFBO) {
|
if (!_glFBO) {
|
||||||
GL_CALL(glGenFramebuffers(1, &_glFBO));
|
GL_CALL(glGenFramebuffers(1, &_glFBO));
|
||||||
|
|
|
@ -31,25 +31,12 @@ namespace OpenGL {
|
||||||
* Object describing a framebuffer OpenGL can render to.
|
* Object describing a framebuffer OpenGL can render to.
|
||||||
*/
|
*/
|
||||||
class Framebuffer {
|
class Framebuffer {
|
||||||
|
friend class Pipeline;
|
||||||
public:
|
public:
|
||||||
Framebuffer();
|
Framebuffer();
|
||||||
virtual ~Framebuffer() {};
|
virtual ~Framebuffer() {};
|
||||||
|
|
||||||
/**
|
public:
|
||||||
* 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();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the clear color of the framebuffer.
|
* Set the clear color of the framebuffer.
|
||||||
*/
|
*/
|
||||||
|
@ -82,6 +69,33 @@ protected:
|
||||||
|
|
||||||
GLfloat _projectionMatrix[4*4];
|
GLfloat _projectionMatrix[4*4];
|
||||||
void applyProjectionMatrix();
|
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:
|
private:
|
||||||
bool _isActive;
|
bool _isActive;
|
||||||
|
|
||||||
|
@ -103,12 +117,13 @@ private:
|
||||||
*/
|
*/
|
||||||
class Backbuffer : public Framebuffer {
|
class Backbuffer : public Framebuffer {
|
||||||
public:
|
public:
|
||||||
virtual void activate();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the dimensions (a.k.a. size) of the back buffer.
|
* Set the dimensions (a.k.a. size) of the back buffer.
|
||||||
*/
|
*/
|
||||||
void setDimensions(uint width, uint height);
|
void setDimensions(uint width, uint height);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void activateInternal();
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !USE_FORCED_GLES
|
#if !USE_FORCED_GLES
|
||||||
|
@ -125,8 +140,6 @@ public:
|
||||||
TextureTarget();
|
TextureTarget();
|
||||||
virtual ~TextureTarget();
|
virtual ~TextureTarget();
|
||||||
|
|
||||||
virtual void activate();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify that the GL context is about to be destroyed.
|
* Notify that the GL context is about to be destroyed.
|
||||||
*/
|
*/
|
||||||
|
@ -146,6 +159,10 @@ public:
|
||||||
* Query pointer to underlying GL texture.
|
* Query pointer to underlying GL texture.
|
||||||
*/
|
*/
|
||||||
GLTexture *getTexture() const { return _texture; }
|
GLTexture *getTexture() const { return _texture; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void activateInternal();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLTexture *_texture;
|
GLTexture *_texture;
|
||||||
GLuint _glFBO;
|
GLuint _glFBO;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue