mirror of https://github.com/mgba-emu/mgba.git
Qt: Improve GL syncing
This commit is contained in:
parent
2781a2a9f9
commit
787c99b949
|
@ -98,6 +98,9 @@ public:
|
||||||
void setInputController(InputController*);
|
void setInputController(InputController*);
|
||||||
void setLogger(LogController*);
|
void setLogger(LogController*);
|
||||||
|
|
||||||
|
bool audioSync() const { return m_audioSync; }
|
||||||
|
bool videoSync() const { return m_videoSync; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
|
@ -20,7 +20,7 @@ Display* Display::create(QWidget* parent) {
|
||||||
#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)
|
#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)
|
||||||
QSurfaceFormat format;
|
QSurfaceFormat format;
|
||||||
format.setSwapInterval(1);
|
format.setSwapInterval(1);
|
||||||
format.setSwapBehavior(QSurfaceFormat::TripleBuffer);
|
format.setSwapBehavior(QSurfaceFormat::SingleBuffer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (s_driver) {
|
switch (s_driver) {
|
||||||
|
|
|
@ -264,11 +264,12 @@ PainterGL::PainterGL(VideoProxy* proxy, QWindow* surface, QOpenGLContext* parent
|
||||||
if (!painter->m_gl->isValid()) {
|
if (!painter->m_gl->isValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
painter->m_gl->doneCurrent();
|
||||||
|
painter->m_gl->swapBuffers(painter->m_surface);
|
||||||
painter->m_gl->makeCurrent(painter->m_surface);
|
painter->m_gl->makeCurrent(painter->m_surface);
|
||||||
#if defined(_WIN32) && defined(USE_EPOXY)
|
#if defined(_WIN32) && defined(USE_EPOXY)
|
||||||
epoxy_handle_external_wglMakeCurrent();
|
epoxy_handle_external_wglMakeCurrent();
|
||||||
#endif
|
#endif
|
||||||
painter->m_gl->swapBuffers(painter->m_gl->surface());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
m_backend->init(m_backend, 0);
|
m_backend->init(m_backend, 0);
|
||||||
|
@ -383,7 +384,7 @@ void PainterGL::draw() {
|
||||||
m_backend->swap(m_backend);
|
m_backend->swap(m_backend);
|
||||||
if (!m_delayTimer.isValid()) {
|
if (!m_delayTimer.isValid()) {
|
||||||
m_delayTimer.start();
|
m_delayTimer.start();
|
||||||
} else if (m_gl->format().swapInterval()) {
|
} else if (m_gl->format().swapInterval() && m_context->videoSync()) {
|
||||||
while (m_delayTimer.elapsed() < 15) {
|
while (m_delayTimer.elapsed() < 15) {
|
||||||
QThread::usleep(100);
|
QThread::usleep(100);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue