Commit 9f2edb43 authored by Jan Möbius's avatar Jan Möbius

Made QtViewer Qt4.6 capable

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9353 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 422fc103
......@@ -55,6 +55,7 @@
#include <QPaintEngine>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsSceneDragDropEvent>
#include <QApplication>
//== NAMESPACES ===============================================================
......@@ -71,15 +72,40 @@ QtGLGraphicsScene::QtGLGraphicsScene(QtBaseViewer* _w) :
}
void QtGLGraphicsScene::drawBackground(QPainter *_painter, const QRectF &)
void QtGLGraphicsScene::drawBackground(QPainter *_painter, const QRectF &_rect)
{
if (_painter->paintEngine()->type() != QPaintEngine::OpenGL) {
std::cerr << "QtGLGraphicsScene: drawBackground needs a QGLWidget to be set as viewport on the graphics view\n";
return;
}
w_->paintGL();
// Check for switch in qt4.6 to OpenGL2
#if QT_VERSION >= 0x040600
if (_painter->paintEngine()->type() != QPaintEngine::OpenGL && _painter->paintEngine()->type() != QPaintEngine::OpenGL2 ) {
std::cerr << "QtGLGraphicsScene: drawBackground needs a QGLWidget to be set as viewport on the graphics view\n";
return;
}
#else
if (_painter->paintEngine()->type() != QPaintEngine::OpenGL ) {
std::cerr << "QtGLGraphicsScene: drawBackground needs a QGLWidget to be set as viewport on the graphics view\n";
return;
}
#endif
// Initialize background first
_painter->setBackground(QApplication::palette().window());
_painter->eraseRect(_rect);
// From now on we do OpenGL direct painting on the scene
#if QT_VERSION >= 0x040600
// Tell Qt that we directly use OpenGL
_painter->beginNativePainting();
#endif
// Clear the depth buffer (This is required since QT4.6 Otherwise we get an emtpty scene!
glClear(GL_DEPTH_BUFFER_BIT);
w_->paintGL();
#if QT_VERSION >= 0x040600
// The rest is painting through QT again.
_painter->endNativePainting();
#endif
}
......
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