Remove 'Default' FBO binding (only allow 'Read' and 'Draw')

Also make code more verbose by removing default mode
parameter value to 'FBO::bind'
This commit is contained in:
Jonas Kulla 2013-09-06 14:56:30 +02:00
parent abc927c91d
commit 6c7d751dbd
5 changed files with 11 additions and 13 deletions

View File

@ -63,7 +63,7 @@ struct BitmapPrivate
void bindFBO() void bindFBO()
{ {
FBO::bind(tex.fbo); FBO::bind(tex.fbo, FBO::Draw);
} }
void pushSetViewport() const void pushSetViewport() const
@ -418,7 +418,7 @@ void Bitmap::hueChange(int hue)
shader.setHueAdjust(hueAdj); shader.setHueAdjust(hueAdj);
shader.setInputTexture(p->tex.tex); shader.setInputTexture(p->tex.tex);
FBO::bind(newTex.fbo); FBO::bind(newTex.fbo, FBO::Draw);
TEX::bindMatrix(width(), height()); TEX::bindMatrix(width(), height());
p->pushSetViewport(); p->pushSetViewport();

View File

@ -159,8 +159,7 @@ namespace FBO
enum Mode enum Mode
{ {
Draw = 0, Draw = 0,
Read = 1, Read = 1
Default = 2
}; };
inline ID gen() inline ID gen()
@ -176,19 +175,18 @@ namespace FBO
glDeleteFramebuffersEXT(1, &id.gl); glDeleteFramebuffersEXT(1, &id.gl);
} }
inline void bind(ID id, Mode mode = Default) inline void bind(ID id, Mode mode)
{ {
static const GLenum modes[] = static const GLenum modes[] =
{ {
GL_DRAW_FRAMEBUFFER_EXT, GL_DRAW_FRAMEBUFFER_EXT,
GL_READ_FRAMEBUFFER_EXT, GL_READ_FRAMEBUFFER_EXT
GL_FRAMEBUFFER_EXT
}; };
glBindFramebufferEXT(modes[mode], id.gl); glBindFramebufferEXT(modes[mode], id.gl);
} }
inline void unbind(Mode mode = Default) inline void unbind(Mode mode)
{ {
bind(ID(0), mode); bind(ID(0), mode);
} }
@ -348,7 +346,7 @@ struct TEXFBO
static inline void linkFBO(TEXFBO &obj) static inline void linkFBO(TEXFBO &obj)
{ {
FBO::bind(obj.fbo); FBO::bind(obj.fbo, FBO::Draw);
FBO::setTarget(obj.tex); FBO::setTarget(obj.tex);
} }
@ -387,7 +385,7 @@ struct RBOFBO
static inline void linkFBO(RBOFBO &obj) static inline void linkFBO(RBOFBO &obj)
{ {
FBO::bind(obj.fbo); FBO::bind(obj.fbo, FBO::Draw);
FBO::setTarget(obj.rbo); FBO::setTarget(obj.rbo);
} }

View File

@ -722,7 +722,7 @@ void Graphics::transition(int duration,
/* Draw the composed frame to a buffer first /* Draw the composed frame to a buffer first
* (we need this because we're skipping PingPong) */ * (we need this because we're skipping PingPong) */
FBO::bind(p->transBuffer.fbo); FBO::bind(p->transBuffer.fbo, FBO::Draw);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
p->screenQuad.draw(); p->screenQuad.draw();

View File

@ -478,7 +478,7 @@ struct TilemapPrivate
QVector<uint8_t> &animatedATs = atlas.animatedATs; QVector<uint8_t> &animatedATs = atlas.animatedATs;
/* Clear atlas */ /* Clear atlas */
FBO::bind(atlas.gl.fbo); FBO::bind(atlas.gl.fbo, FBO::Draw);
glState.clearColor.pushSet(Vec4()); glState.clearColor.pushSet(Vec4());
glState.scissorTest.pushSet(false); glState.scissorTest.pushSet(false);

View File

@ -418,7 +418,7 @@ struct WindowPrivate
TEX::allocEmpty(baseTex.width, baseTex.height); TEX::allocEmpty(baseTex.width, baseTex.height);
TEX::unbind(); TEX::unbind();
FBO::bind(baseTex.fbo); FBO::bind(baseTex.fbo, FBO::Draw);
glState.pushSetViewport(baseTex.width, baseTex.height); glState.pushSetViewport(baseTex.width, baseTex.height);
glState.clearColor.pushSet(Vec4()); glState.clearColor.pushSet(Vec4());