summaryrefslogtreecommitdiff
path: root/src/citra_qt/bootmanager.cpp
diff options
context:
space:
mode:
authorGravatar Sacha2014-08-25 00:47:00 +1000
committerGravatar Sacha2014-08-25 00:47:00 +1000
commita3a70e56acfde2cf75dfd02a6c2f1828d28efe02 (patch)
tree56e2fb6a10d72abedebb83c1681f9cddbe7462e4 /src/citra_qt/bootmanager.cpp
parentMerge pull request #73 from yuriks/remove-docs (diff)
downloadyuzu-a3a70e56acfde2cf75dfd02a6c2f1828d28efe02.tar.gz
yuzu-a3a70e56acfde2cf75dfd02a6c2f1828d28efe02.tar.xz
yuzu-a3a70e56acfde2cf75dfd02a6c2f1828d28efe02.zip
Fix the threading for GL Context in Qt5.
Connect the emu_thread start/finish to a moveContext slot.
Diffstat (limited to 'src/citra_qt/bootmanager.cpp')
-rw-r--r--src/citra_qt/bootmanager.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index b0aa1e561..73f25e691 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -1,5 +1,6 @@
1#include <QHBoxLayout> 1#include <QHBoxLayout>
2#include <QKeyEvent> 2#include <QKeyEvent>
3#include <QApplication>
3 4
4#include "common/common.h" 5#include "common/common.h"
5#include "bootmanager.hxx" 6#include "bootmanager.hxx"
@@ -79,15 +80,11 @@ class GGLWidgetInternal : public QGLWidget
79public: 80public:
80 GGLWidgetInternal(QGLFormat fmt, GRenderWindow* parent) : QGLWidget(parent) 81 GGLWidgetInternal(QGLFormat fmt, GRenderWindow* parent) : QGLWidget(parent)
81 { 82 {
82 doneCurrent();
83 parent_ = parent; 83 parent_ = parent;
84 } 84 }
85 85
86 void paintEvent(QPaintEvent* ev) 86 void paintEvent(QPaintEvent* ev)
87 { 87 {
88 // Apparently, Windows doesn't display anything if we don't call this here.
89 // TODO: Breaks linux though because we aren't calling doneCurrent() ... -.-
90// makeCurrent();
91 } 88 }
92 void resizeEvent(QResizeEvent* ev) { 89 void resizeEvent(QResizeEvent* ev) {
93 parent_->SetClientAreaWidth(size().width()); 90 parent_->SetClientAreaWidth(size().width());
@@ -118,10 +115,22 @@ GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this
118 layout->addWidget(child); 115 layout->addWidget(child);
119 layout->setMargin(0); 116 layout->setMargin(0);
120 setLayout(layout); 117 setLayout(layout);
118 QObject::connect(&emu_thread, SIGNAL(started()), this, SLOT(moveContext()));
119 QObject::connect(&emu_thread, SIGNAL(finished()), this, SLOT(moveContext()));
121 120
122 BackupGeometry(); 121 BackupGeometry();
123} 122}
124 123
124void GRenderWindow::moveContext()
125{
126 DoneCurrent();
127 // We need to move GL context to the swapping thread in Qt5
128#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
129 // If the thread started running, move the GL Context to the new thread. Otherwise, move it back.
130 child->context()->moveToThread(emu_thread.isRunning() ? &emu_thread : qApp->thread());
131#endif
132}
133
125GRenderWindow::~GRenderWindow() 134GRenderWindow::~GRenderWindow()
126{ 135{
127 emu_thread.Stop(); 136 emu_thread.Stop();
@@ -129,7 +138,7 @@ GRenderWindow::~GRenderWindow()
129 138
130void GRenderWindow::SwapBuffers() 139void GRenderWindow::SwapBuffers()
131{ 140{
132 child->makeCurrent(); // TODO: Not necessary? 141 // MakeCurrent is already called in renderer_opengl
133 child->swapBuffers(); 142 child->swapBuffers();
134} 143}
135 144
@@ -212,4 +221,5 @@ void GRenderWindow::keyReleaseEvent(QKeyEvent* event)
212 if (!key_processed) 221 if (!key_processed)
213 QWidget::keyPressEvent(event); 222 QWidget::keyPressEvent(event);
214 */ 223 */
215} \ No newline at end of file 224}
225