Fixed OpenGL viewport being updated at each frame
That could cause ratio flickering on paint() on some devices
This commit is contained in:
parent
9b2c60fe16
commit
1077e4dca3
2 changed files with 16 additions and 1 deletions
|
@ -18,6 +18,8 @@ OpenGLView::OpenGLView(QQuickItem *parent) :
|
||||||
mouse_button = Qt::NoButton;
|
mouse_button = Qt::NoButton;
|
||||||
|
|
||||||
connect(this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(handleWindowChanged(QQuickWindow*)));
|
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);
|
startTimer(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,9 +47,15 @@ void OpenGLView::paint()
|
||||||
{
|
{
|
||||||
renderer->initialize();
|
renderer->initialize();
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
resized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (resized)
|
||||||
|
{
|
||||||
renderer->resize(width(), height());
|
renderer->resize(width(), height());
|
||||||
|
resized = false;
|
||||||
|
}
|
||||||
|
|
||||||
renderer->prepareOpenGLState();
|
renderer->prepareOpenGLState();
|
||||||
renderer->paint();
|
renderer->paint();
|
||||||
|
|
||||||
|
@ -57,6 +65,11 @@ void OpenGLView::paint()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenGLView::handleResize()
|
||||||
|
{
|
||||||
|
resized = true;
|
||||||
|
}
|
||||||
|
|
||||||
void OpenGLView::wheelEvent(QWheelEvent *event)
|
void OpenGLView::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
if (not acceptInputs())
|
if (not acceptInputs())
|
||||||
|
|
|
@ -17,6 +17,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void handleWindowChanged(QQuickWindow *win);
|
void handleWindowChanged(QQuickWindow *win);
|
||||||
void paint();
|
void paint();
|
||||||
|
void handleResize();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void wheelEvent(QWheelEvent *event) override;
|
virtual void wheelEvent(QWheelEvent *event) override;
|
||||||
|
@ -31,6 +32,7 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool initialized;
|
bool initialized;
|
||||||
|
bool resized;
|
||||||
MainModelerWindow *window;
|
MainModelerWindow *window;
|
||||||
OpenGLRenderer *renderer;
|
OpenGLRenderer *renderer;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue