diff options
author | Sergey Dubitskiy <sergey.dubitskiy@nokia.com> | 2012-07-13 11:16:07 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-18 03:16:35 +0200 |
commit | d9231b99acd57f442159e91381fa3027fb0add8f (patch) | |
tree | bea27fd53c04e00cdb2403ba70f22c937074ad71 /demos | |
parent | d5782880c2c668a3848691f21917c00d5979945f (diff) |
QGLSubsurface was fixed. Qt3d "Shapes" demo now works on Mac.
On Mac, GL scene is not repainted when window is resized.
But his issue is not related to qt3d...
Task-number: QTBUG-26392
Task-number: QTBUG-26391
Change-Id: I9cb30b2975acd2ef07037560bc964d23f797442e
Reviewed-by: Danny Pope <daniel.pope@nokia.com>
Diffstat (limited to 'demos')
-rw-r--r-- | demos/qt3d/shapes/shapes.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/demos/qt3d/shapes/shapes.cpp b/demos/qt3d/shapes/shapes.cpp index 3bd09bc5f..17157e51e 100644 --- a/demos/qt3d/shapes/shapes.cpp +++ b/demos/qt3d/shapes/shapes.cpp @@ -171,8 +171,11 @@ void ShapesWidget::paintGL() glDisable(GL_DEPTH_TEST); + QRect rect = geometry(); + QRect rectnew(0,0,rect.width(),rect.height()); + QMatrix4x4 projm; - projm.ortho(geometry()); + projm.ortho(rectnew); painter.projectionMatrix() = projm; painter.modelViewMatrix().setToIdentity(); @@ -226,6 +229,8 @@ void ShapesWidget::paintPoints(QGLPainter *painter, const QRect& rect) void ShapesWidget::paintLines(QGLPainter *painter, const QRect& rect) { painter->clearAttributes(); + painter->setStandardEffect(QGL::FlatColor); + painter->setColor(QColor(170, 202, 0)); painter->setVertexAttribute(QGL::Position, basicPoints(rect)); painter->draw(QGL::Lines, 8); @@ -235,6 +240,8 @@ void ShapesWidget::paintLines(QGLPainter *painter, const QRect& rect) void ShapesWidget::paintLineStrip(QGLPainter *painter, const QRect& rect) { painter->clearAttributes(); + painter->setStandardEffect(QGL::FlatColor); + painter->setColor(QColor(170, 202, 0)); painter->setVertexAttribute(QGL::Position, basicPoints(rect)); painter->draw(QGL::LineStrip, 8); @@ -244,6 +251,8 @@ void ShapesWidget::paintLineStrip(QGLPainter *painter, const QRect& rect) void ShapesWidget::paintLineLoop(QGLPainter *painter, const QRect& rect) { painter->clearAttributes(); + painter->setStandardEffect(QGL::FlatColor); + painter->setColor(QColor(170, 202, 0)); painter->setVertexAttribute(QGL::Position, basicPoints(rect)); painter->draw(QGL::LineLoop, 8); @@ -368,16 +377,19 @@ void ShapesWidget::paintCube(QGLPainter *painter, const QRect& rect) painter->projectionMatrix().push(); painter->modelViewMatrix().push(); - QMatrix4x4 cubeTransform; - cubeTransform.translate(0,-2.5,-12); - cubeTransform.rotate(45.0f, 1.0f, 1.0f, 1.0f); - cube->setLocalTransform(cubeTransform); + QGLSubsurface surface(painter->currentSurface(), rect); + painter->pushSurface(&surface); + painter->setCamera(&camera); + painter->modelViewMatrix().rotate(45.0f, 1.0f, 1.0f, 1.0f); + cube->draw(painter); painter->projectionMatrix().pop(); painter->modelViewMatrix().pop(); + painter->popSurface(); + drawText(painter, rect, tr("Cube")); } @@ -388,12 +400,9 @@ void ShapesWidget::paintTeapot(QGLPainter *painter, const QRect& rect) painter->projectionMatrix().push(); painter->modelViewMatrix().push(); - QRect view = geometry(); - qreal aspect = ((qreal)view.width())/((qreal)view.height()); - qreal ratio = aspect/1.333; - QMatrix4x4 teapotTransform; - teapotTransform.translate(4*ratio,-2.5,-12.0); - teapot->setLocalTransform(teapotTransform); + QGLSubsurface surface(painter->currentSurface(), rect); + painter->pushSurface(&surface); + painter->setCamera(&camera); // Need a one-sided lighting model for the teapot. painter->setLightModel(&oneSidedModel); @@ -404,6 +413,8 @@ void ShapesWidget::paintTeapot(QGLPainter *painter, const QRect& rect) painter->projectionMatrix().pop(); painter->modelViewMatrix().pop(); + painter->popSurface(); + drawText(painter, rect, tr("Teapot")); } |