mirror of https://github.com/mgba-emu/mgba.git
Fix flickering when resizing emulator window
This commit is contained in:
parent
113d7da345
commit
1ef3f4256f
|
@ -64,7 +64,7 @@ void Display::initializeGL() {
|
||||||
|
|
||||||
void Display::resizeEvent(QResizeEvent* event) {
|
void Display::resizeEvent(QResizeEvent* event) {
|
||||||
if (m_painter) {
|
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) {
|
void Painter::resize(const QSize& size) {
|
||||||
m_size = 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() {
|
void Painter::start() {
|
||||||
|
|
|
@ -39,12 +39,12 @@ public:
|
||||||
void setContext(GBAThread*);
|
void setContext(GBAThread*);
|
||||||
void setBacking(const uint32_t*);
|
void setBacking(const uint32_t*);
|
||||||
void setGLContext(QGLWidget*);
|
void setGLContext(QGLWidget*);
|
||||||
void resize(const QSize& size);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void draw();
|
void draw();
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
void resize(const QSize& size);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTimer* m_drawTimer;
|
QTimer* m_drawTimer;
|
||||||
|
|
Loading…
Reference in New Issue