Commit 362324d6 authored by schultz's avatar schultz

applied changes from code review for MSAA fix

parent 93d9766a
...@@ -138,7 +138,7 @@ glViewer::glViewer( QGraphicsScene* _scene, ...@@ -138,7 +138,7 @@ glViewer::glViewer( QGraphicsScene* _scene,
glDebugLogger_(0), glDebugLogger_(0),
#endif #endif
pickCache_(0), pickCache_(0),
mouseCache_(0), mouseCache_(nullptr),
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),
...@@ -1574,11 +1574,9 @@ void glViewer::mousePressEvent(QGraphicsSceneMouseEvent* _e) ...@@ -1574,11 +1574,9 @@ void glViewer::mousePressEvent(QGraphicsSceneMouseEvent* _e)
emit signalMakeActive(); emit signalMakeActive();
const GLuint prevFBO = ACG::GLState::getFramebufferDraw(); const GLuint prevFBO = ACG::GLState::getFramebufferDraw();
static unsigned int creationHeight = 0;
static unsigned int creationWidth = 0;
static GLuint fboHandle;
//recreate FBO if gl area was resized //recreate FBO if gl area was resized
if (mouseCache_ != nullptr && (glWidth() != creationWidth || glHeight() != creationHeight)) if (mouseCache_ != nullptr && QFBOResized(mouseCache_))
{ {
deleteQFBO(mouseCache_); deleteQFBO(mouseCache_);
mouseCache_ = nullptr; mouseCache_ = nullptr;
...@@ -1586,13 +1584,13 @@ void glViewer::mousePressEvent(QGraphicsSceneMouseEvent* _e) ...@@ -1586,13 +1584,13 @@ void glViewer::mousePressEvent(QGraphicsSceneMouseEvent* _e)
if (mouseCache_ == nullptr) if (mouseCache_ == nullptr)
{ {
GLuint fboHandle;
int samples = 0; int samples = 0;
creationHeight = glHeight(); createQFBO(mouseCache_, &fboHandle, glWidth() , glHeight(), &samples);
creationWidth = glWidth();
createQFBO(mouseCache_, &fboHandle, creationWidth, creationHeight, &samples);
} }
ACG::GLState::bindFramebuffer(GL_FRAMEBUFFER_EXT, fboHandle); bindQFBO(mouseCache_);
glScene_->update (); glScene_->update ();
// right button pressed => popup menu (ignore here) // right button pressed => popup menu (ignore here)
......
...@@ -573,6 +573,8 @@ private: ...@@ -573,6 +573,8 @@ private:
// wrapper to create QFramebufferObject returns true if QFBO is valid if samples is -1 the default samples are retrieved // wrapper to create QFramebufferObject returns true if QFBO is valid if samples is -1 the default samples are retrieved
bool createQFBO(QOpenGLFramebufferObject*& _ptr, GLuint* _handle, int _width, int _height, int* _samples); bool createQFBO(QOpenGLFramebufferObject*& _ptr, GLuint* _handle, int _width, int _height, int* _samples);
bool bindQFBO(QOpenGLFramebufferObject* _ptr);
bool QFBOResized(QOpenGLFramebufferObject* _ptr);
void blitQFBO(QOpenGLFramebufferObject* _ptr1, const QRect& _size1, QOpenGLFramebufferObject* _ptr2, const QRect& _size2); void blitQFBO(QOpenGLFramebufferObject* _ptr1, const QRect& _size1, QOpenGLFramebufferObject* _ptr2, const QRect& _size2);
void deleteQFBO(QOpenGLFramebufferObject* _ptr); void deleteQFBO(QOpenGLFramebufferObject* _ptr);
......
...@@ -214,6 +214,20 @@ void glViewer::blitQFBO(QOpenGLFramebufferObject* _ptr1, const QRect& _size1, QO ...@@ -214,6 +214,20 @@ void glViewer::blitQFBO(QOpenGLFramebufferObject* _ptr1, const QRect& _size1, QO
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool glViewer::bindQFBO(QOpenGLFramebufferObject* _ptr)
{
return _ptr->bind();
}
//-----------------------------------------------------------------------------
bool glViewer::QFBOResized(QOpenGLFramebufferObject* _ptr1)
{
return _ptr1->size() != QSize(glWidth(), glHeight());
}
//-----------------------------------------------------------------------------
void glViewer::deleteQFBO(QOpenGLFramebufferObject* _ptr) void glViewer::deleteQFBO(QOpenGLFramebufferObject* _ptr)
{ {
delete _ptr; delete _ptr;
......
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