Commit 77c3438b authored by Martin Schultz's avatar Martin Schultz
Browse files

fixes #13 by using a non multisampled FBO for picking

parent 3674f2d6
...@@ -1563,12 +1563,19 @@ void glViewer::contextMenuEvent(QGraphicsSceneContextMenuEvent* _e) ...@@ -1563,12 +1563,19 @@ void glViewer::contextMenuEvent(QGraphicsSceneContextMenuEvent* _e)
void glViewer::mousePressEvent(QGraphicsSceneMouseEvent* _e) void glViewer::mousePressEvent(QGraphicsSceneMouseEvent* _e)
{ {
makeCurrent();
QPoint p (_e->scenePos().x(), _e->scenePos().y()); QPoint p (_e->scenePos().x(), _e->scenePos().y());
QMouseEvent me(QEvent::MouseButtonPress ,p, _e->screenPos(), _e->button(), QMouseEvent me(QEvent::MouseButtonPress ,p, _e->screenPos(), _e->button(),
_e->buttons(), _e->modifiers()); _e->buttons(), _e->modifiers());
_e->accept (); _e->accept ();
emit signalMakeActive(); emit signalMakeActive();
const GLuint prevFBO = ACG::GLState::getFramebufferDraw();
QFramebufferObject* nonMultisampledFBO;
GLuint fboHandle;
int samples = 0;
createQFBO(nonMultisampledFBO,&fboHandle,glWidth(),glHeight(),&samples);
ACG::GLState::bindFramebuffer(GL_FRAMEBUFFER_EXT, fboHandle);
glScene_->update (); glScene_->update ();
// right button pressed => popup menu (ignore here) // right button pressed => popup menu (ignore here)
...@@ -1608,6 +1615,10 @@ void glViewer::mousePressEvent(QGraphicsSceneMouseEvent* _e) ...@@ -1608,6 +1615,10 @@ void glViewer::mousePressEvent(QGraphicsSceneMouseEvent* _e)
break; break;
} }
} }
//restore old FBO
ACG::GLState::bindFramebuffer(GL_FRAMEBUFFER_EXT,prevFBO);
//cleanup
deleteQFBO(nonMultisampledFBO);
} }
...@@ -1894,7 +1905,7 @@ void glViewer::handleNormalNavigation( QMouseEvent* _event ) { ...@@ -1894,7 +1905,7 @@ void glViewer::handleNormalNavigation( QMouseEvent* _event ) {
switch (_event->type()) { switch (_event->type()) {
case QEvent::MouseButtonPress: { case QEvent::MouseButtonPress: {
// Get the depth at the current mouse position ( projected ) // Get the depth at the current mouse position ( projected )
// This is used to do the translation in world coordinates // This is used to do the translation in world coordinates
// As the scene is rendered, we can get the depth directly from the framebuffer. // As the scene is rendered, we can get the depth directly from the framebuffer.
......
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