all repos — mgba @ 1ef3f4256faabc8a7caa029b1c21ea52bba4879d

mGBA Game Boy Advance Emulator

Fix flickering when resizing emulator window
Jeffrey Pfau jeffrey@endrift.com
Wed, 15 Oct 2014 02:28:32 -0700
commit

1ef3f4256faabc8a7caa029b1c21ea52bba4879d

parent

113d7da345b844fa087058a4b26295301a39f57b

2 files changed, 7 insertions(+), 2 deletions(-)

jump to
M src/platform/qt/Display.cppsrc/platform/qt/Display.cpp

@@ -64,7 +64,7 @@ }

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::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() {
M src/platform/qt/Display.hsrc/platform/qt/Display.h

@@ -39,12 +39,12 @@

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;