From 1077e4dca34d63540d3aa45cd6d74e55f27bce7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Mon, 24 Aug 2015 19:38:59 +0200 Subject: [PATCH] Fixed OpenGL viewport being updated at each frame That could cause ratio flickering on paint() on some devices --- src/interface/modeler/quickapp/OpenGLView.cpp | 15 ++++++++++++++- src/interface/modeler/quickapp/OpenGLView.h | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/interface/modeler/quickapp/OpenGLView.cpp b/src/interface/modeler/quickapp/OpenGLView.cpp index cc828e6..e1a90f8 100644 --- a/src/interface/modeler/quickapp/OpenGLView.cpp +++ b/src/interface/modeler/quickapp/OpenGLView.cpp @@ -18,6 +18,8 @@ OpenGLView::OpenGLView(QQuickItem *parent) : mouse_button = Qt::NoButton; connect(this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(handleWindowChanged(QQuickWindow*))); + connect(this, SIGNAL(widthChanged()), this, SLOT(handleResize())); + connect(this, SIGNAL(heightChanged()), this, SLOT(handleResize())); startTimer(50); } @@ -45,9 +47,15 @@ void OpenGLView::paint() { renderer->initialize(); initialized = true; + resized = true; + } + + if (resized) + { + renderer->resize(width(), height()); + resized = false; } - renderer->resize(width(), height()); renderer->prepareOpenGLState(); renderer->paint(); @@ -57,6 +65,11 @@ void OpenGLView::paint() } } +void OpenGLView::handleResize() +{ + resized = true; +} + void OpenGLView::wheelEvent(QWheelEvent *event) { if (not acceptInputs()) diff --git a/src/interface/modeler/quickapp/OpenGLView.h b/src/interface/modeler/quickapp/OpenGLView.h index 5a6fc99..58f2075 100644 --- a/src/interface/modeler/quickapp/OpenGLView.h +++ b/src/interface/modeler/quickapp/OpenGLView.h @@ -17,6 +17,7 @@ public: public slots: void handleWindowChanged(QQuickWindow *win); void paint(); + void handleResize(); protected: virtual void wheelEvent(QWheelEvent *event) override; @@ -31,6 +32,7 @@ private: private: bool initialized; + bool resized; MainModelerWindow *window; OpenGLRenderer *renderer;