Commit 93d9766a authored by schultz's avatar schultz

only create the FBO once, or recreate if the size has changed

parent 77c3438b
......@@ -138,6 +138,7 @@ glViewer::glViewer( QGraphicsScene* _scene,
glDebugLogger_(0),
#endif
pickCache_(0),
mouseCache_(0),
updatePickCache_(true),
pickCacheSupported_(true),
constrainedRotationAxis_(std::numeric_limits<double>::quiet_NaN(), 0, 0),
......@@ -217,6 +218,8 @@ glViewer::~glViewer()
delete glstate_;
deleteGLDebugLogger();
if (mouseCache_ != nullptr)
deleteQFBO(mouseCache_);
}
......@@ -1571,10 +1574,24 @@ void glViewer::mousePressEvent(QGraphicsSceneMouseEvent* _e)
emit signalMakeActive();
const GLuint prevFBO = ACG::GLState::getFramebufferDraw();
QFramebufferObject* nonMultisampledFBO;
GLuint fboHandle;
int samples = 0;
createQFBO(nonMultisampledFBO,&fboHandle,glWidth(),glHeight(),&samples);
static unsigned int creationHeight = 0;
static unsigned int creationWidth = 0;
static GLuint fboHandle;
//recreate FBO if gl area was resized
if (mouseCache_ != nullptr && (glWidth() != creationWidth || glHeight() != creationHeight))
{
deleteQFBO(mouseCache_);
mouseCache_ = nullptr;
}
if (mouseCache_ == nullptr)
{
int samples = 0;
creationHeight = glHeight();
creationWidth = glWidth();
createQFBO(mouseCache_, &fboHandle, creationWidth, creationHeight, &samples);
}
ACG::GLState::bindFramebuffer(GL_FRAMEBUFFER_EXT, fboHandle);
glScene_->update ();
......@@ -1617,8 +1634,6 @@ void glViewer::mousePressEvent(QGraphicsSceneMouseEvent* _e)
}
//restore old FBO
ACG::GLState::bindFramebuffer(GL_FRAMEBUFFER_EXT,prevFBO);
//cleanup
deleteQFBO(nonMultisampledFBO);
}
......
......@@ -889,6 +889,7 @@ private:
/// Framebuffer object that holds the pick cache
QFramebufferObject* pickCache_;
QFramebufferObject* mouseCache_;
/// Should the pick cache be updated
bool updatePickCache_;
......
Markdown is supported
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