From 1ef3f4256faabc8a7caa029b1c21ea52bba4879d Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 15 Oct 2014 02:28:32 -0700 Subject: [PATCH] Fix flickering when resizing emulator window --- src/platform/qt/Display.cpp | 7 ++++++- src/platform/qt/Display.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/platform/qt/Display.cpp b/src/platform/qt/Display.cpp index 492437dd2..3b477c0e9 100644 --- a/src/platform/qt/Display.cpp +++ b/src/platform/qt/Display.cpp @@ -64,7 +64,7 @@ void Display::initializeGL() { void Display::resizeEvent(QResizeEvent* event) { if (m_painter) { - m_painter->resize(event->size()); + QMetaObject::invokeMethod(m_painter, "resize", Qt::BlockingQueuedConnection, Q_ARG(QSize, event->size())); } } @@ -86,6 +86,11 @@ void Painter::setGLContext(QGLWidget* context) { void Painter::resize(const QSize& size) { m_size = size; + m_gl->makeCurrent(); + glViewport(0, 0, m_size.width() * m_gl->devicePixelRatio(), m_size.height() * m_gl->devicePixelRatio()); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + m_gl->swapBuffers(); + m_gl->doneCurrent(); } void Painter::start() { diff --git a/src/platform/qt/Display.h b/src/platform/qt/Display.h index 6d6d91ed2..2513e4053 100644 --- a/src/platform/qt/Display.h +++ b/src/platform/qt/Display.h @@ -39,12 +39,12 @@ public: void setContext(GBAThread*); void setBacking(const uint32_t*); void setGLContext(QGLWidget*); - void resize(const QSize& size); public slots: void draw(); void start(); void stop(); + void resize(const QSize& size); private: QTimer* m_drawTimer;