Skip to content

Commit

Permalink
Reset also viewport to default framebuffer on named FB destruction.
Browse files Browse the repository at this point in the history
In text example the scene was rendered with viewport used for
distance field computation, which is wrong. Also amazingly enough that
worked until now.
  • Loading branch information
mosra committed Jun 29, 2014
1 parent dc98045 commit 50897e0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Magnum/Framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <Corrade/Containers/Array.h>

#include "Magnum/Context.h"
#include "Magnum/DefaultFramebuffer.h"
#include "Magnum/Extensions.h"
#include "Magnum/Image.h"
#include "Magnum/Renderbuffer.h"
Expand Down Expand Up @@ -92,7 +93,17 @@ Framebuffer::~Framebuffer() {
/* If bound, remove itself from state */
Implementation::FramebufferState* state = Context::current()->state().framebuffer;
if(state->readBinding == _id) state->readBinding = 0;
if(state->drawBinding == _id) state->drawBinding = 0;

/* For draw binding reset also viewport */
if(state->drawBinding == _id) {
state->drawBinding = 0;

/**
* @todo Less ugly solution (need to call setViewportInternal() to
* reset the viewport to size of default framebuffer)
*/
defaultFramebuffer.bind(FramebufferTarget::Draw);
}

glDeleteFramebuffers(1, &_id);
}
Expand Down

0 comments on commit 50897e0

Please sign in to comment.