Commit 93d9766a authored by schultz's avatar schultz
Browse files

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

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