Commit 369e44f6 authored by Christopher Tenter's avatar Christopher Tenter
Browse files

- fix warning

- restore fbo with correct drawbuffer target

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@19671 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 3b627103
......@@ -1012,8 +1012,8 @@ void GLLineBox::updateVBO()
for (int i = 0; i < 12; ++i)
{
Vec3f p[2] = { pos[lines[i][0]], pos[lines[i][1]]};
Vec3f n[2] = { norm[lines[i][3]], norm[lines[i][4]]};
Vec2f t[2] = { texc[lines[i][6]], texc[lines[i][7]]};
Vec3f n[2] = { norm[lines[i][2]], norm[lines[i][3]]};
Vec2f t[2] = { texc[lines[i][4]], texc[lines[i][5]]};
addLineToVBO(p, n, t);
}
......
......@@ -75,6 +75,7 @@ renderObjects_(0),
depthMapUsed_(false),
curViewerID_(0),
prevFbo_(0),
prevDrawBuffer_(GL_BACK),
prevFboSaved_(false),
depthCopyShader_(0),
errorDetectionLevel_(1),
......@@ -210,7 +211,7 @@ void IRenderer::addRenderObject(ACG::RenderObject* _renderObject)
glGetProgramiv(shaderProg->getProgramId(), GL_GEOMETRY_INPUT_TYPE, &geomInputType);
if (geomInputType != p->primitiveMode)
if (geomInputType != GLint(p->primitiveMode))
{
switch (geomInputType)
......@@ -527,8 +528,10 @@ void IRenderer::finishRenderingPipeline(bool _drawOverlay)
GLint curFbo;
GLint curViewport[4];
GLint curDrawBuf;
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &curFbo);
glGetIntegerv(GL_VIEWPORT, curViewport);
glGetIntegerv(GL_DRAW_BUFFER, &curDrawBuf);
if (curFbo != prevFbo_)
{
......@@ -536,6 +539,12 @@ void IRenderer::finishRenderingPipeline(bool _drawOverlay)
restoreInputFbo();
}
if (curDrawBuf != prevDrawBuffer_)
{
std::cout << "warning: input and output draw-buffer are not the same in renderer implementation" << std::endl;
restoreInputFbo();
}
if (curViewport[0] != prevViewport_[0] ||
curViewport[1] != prevViewport_[1] ||
curViewport[2] != prevViewport_[2] ||
......@@ -550,27 +559,28 @@ void IRenderer::finishRenderingPipeline(bool _drawOverlay)
void IRenderer::saveInputFbo()
{
// save active fbo
saveActiveFbo(&prevFbo_, prevViewport_);
saveActiveFbo(&prevFbo_, prevViewport_, &prevDrawBuffer_);
prevFboSaved_ = true;
}
void IRenderer::restoreInputFbo()
{
if (prevFboSaved_)
restoreFbo(prevFbo_, prevViewport_);
restoreFbo(prevFbo_, prevViewport_, prevDrawBuffer_);
}
void IRenderer::saveActiveFbo( GLint* _outFboId, GLint* _outViewport ) const
void IRenderer::saveActiveFbo( GLint* _outFboId, GLint* _outViewport, GLint* _outDrawBuffer ) const
{
// save active fbo
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, _outFboId);
glGetIntegerv(GL_VIEWPORT, _outViewport);
glGetIntegerv(GL_DRAW_BUFFER, _outDrawBuffer);
}
void IRenderer::restoreFbo( GLint _fboId, const GLint* _outViewport ) const
void IRenderer::restoreFbo( GLint _fboId, const GLint* _outViewport, GLint _drawBuffer ) const
{
glBindFramebuffer(GL_FRAMEBUFFER, _fboId);
glDrawBuffer(_fboId == 0 ? GL_BACK : GL_COLOR_ATTACHMENT0);
glDrawBuffer(_drawBuffer);
glViewport(_outViewport[0], _outViewport[1], _outViewport[2], _outViewport[3]);
}
......@@ -1030,7 +1040,8 @@ void IRenderer::copyDepthToBackBuffer( GLuint _depthTex, float _scale /*= 1.0f*/
// save important opengl states
GLint curFbo;
GLint curViewport[4];
saveActiveFbo(&curFbo, curViewport);
GLint curDrawBuffer;
saveActiveFbo(&curFbo, curViewport, &curDrawBuffer);
GLboolean colorMask[4], depthMask;
glGetBooleanv(GL_COLOR_WRITEMASK, colorMask);
......@@ -1066,7 +1077,7 @@ void IRenderer::copyDepthToBackBuffer( GLuint _depthTex, float _scale /*= 1.0f*/
// restore important opengl states
restoreFbo(curFbo, curViewport);
restoreFbo(curFbo, curViewport, curDrawBuffer);
glColorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]);
glDepthMask(depthMask);
......
......@@ -270,14 +270,16 @@ protected:
/** \brief Save active Fbo configuration (fbo id + viewport)
* @param _outFboId [out] pointer to address receiving the currently active fbo id
* @param _outViewport [out] pointer to address of 4 GLint values receiving the currently active viewport
* @param _outDrawBuffer [out] pointer to address receiving the currently active drawbuffer target (ie GL_BACK, GL_COLOR_ATTACHMENTi ..)
*/
virtual void saveActiveFbo(GLint* _outFboId, GLint* _outViewport) const;
virtual void saveActiveFbo(GLint* _outFboId, GLint* _outViewport, GLint* _outDrawBuffer) const;
/** \brief Restore a previously saved input Fbo configuration (fbo id + viewport)
* @param _fboId pointer to address receiving the currently active fbo id
* @param _fboId fbo id
* @param _outViewport [in] pointer to address of 4 GLint values receiving the currently active viewport
* @param _drawBuffer draw-buffer target of fbo
*/
virtual void restoreFbo(GLint _fboId, const GLint* _outViewport) const;
virtual void restoreFbo(GLint _fboId, const GLint* _outViewport, GLint _drawBuffer) const;
/** \brief Clear input Fbo.
*
......@@ -472,6 +474,9 @@ protected:
/// previous fbo
GLint prevFbo_;
/// previous drawbuffer target (ie GL_BACK, GL_COLOR_ATTACHMENTi...)
GLint prevDrawBuffer_;
/// previous viewport
GLint prevViewport_[4];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment