mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-23 09:00:10 +00:00
Fix wrong threaded usage of OpenGL context.
This fixes crashes on all platform when rendering to the screen.
This commit is contained in:
parent
fab2f28ea5
commit
3c150c4bdb
@ -79,15 +79,11 @@ class GGLWidgetInternal : public QGLWidget
|
||||
public:
|
||||
GGLWidgetInternal(QGLFormat fmt, GRenderWindow* parent) : QGLWidget(parent)
|
||||
{
|
||||
doneCurrent();
|
||||
parent_ = parent;
|
||||
}
|
||||
|
||||
void paintEvent(QPaintEvent* ev)
|
||||
{
|
||||
// Apparently, Windows doesn't display anything if we don't call this here.
|
||||
// TODO: Breaks linux though because we aren't calling doneCurrent() ... -.-
|
||||
// makeCurrent();
|
||||
}
|
||||
void resizeEvent(QResizeEvent* ev) {
|
||||
parent_->SetClientAreaWidth(size().width());
|
||||
@ -97,6 +93,12 @@ private:
|
||||
GRenderWindow* parent_;
|
||||
};
|
||||
|
||||
void GRenderWindow::MoveContextToEmuThread() {
|
||||
// This isn't required in Qt4 and moveToThread doesn't exist there
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
child->context()->moveToThread(&emu_thread);
|
||||
#endif
|
||||
}
|
||||
|
||||
EmuThread& GRenderWindow::GetEmuThread()
|
||||
{
|
||||
@ -129,7 +131,6 @@ GRenderWindow::~GRenderWindow()
|
||||
|
||||
void GRenderWindow::SwapBuffers()
|
||||
{
|
||||
child->makeCurrent(); // TODO: Not necessary?
|
||||
child->swapBuffers();
|
||||
}
|
||||
|
||||
|
@ -98,6 +98,7 @@ public:
|
||||
void restoreGeometry(const QByteArray& geometry); // overridden
|
||||
QByteArray saveGeometry(); // overridden
|
||||
|
||||
void MoveContextToEmuThread();
|
||||
EmuThread& GetEmuThread();
|
||||
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
@ -142,7 +142,8 @@ void GMainWindow::BootGame(std::string filename)
|
||||
registersWidget->OnCPUStepped();
|
||||
callstackWidget->OnCPUStepped();
|
||||
|
||||
render_window->DoneCurrent(); // make sure EmuThread can access GL context
|
||||
render_window->DoneCurrent();
|
||||
render_window->MoveContextToEmuThread();
|
||||
render_window->GetEmuThread().SetFilename(filename);
|
||||
render_window->GetEmuThread().start();
|
||||
|
||||
@ -204,7 +205,6 @@ void GMainWindow::ToggleWindowMode()
|
||||
ui.horizontalLayout->removeWidget(render_window);
|
||||
render_window->setParent(NULL);
|
||||
render_window->setVisible(true);
|
||||
render_window->DoneCurrent();
|
||||
render_window->RestoreGeometry();
|
||||
}
|
||||
else if (!enable && render_window->parent() == NULL)
|
||||
@ -212,7 +212,6 @@ void GMainWindow::ToggleWindowMode()
|
||||
render_window->BackupGeometry();
|
||||
ui.horizontalLayout->addWidget(render_window);
|
||||
render_window->setVisible(true);
|
||||
render_window->DoneCurrent();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ void Init(EmuWindow* emu_window) {
|
||||
glewExperimental = GL_TRUE;
|
||||
|
||||
g_emu_window = emu_window;
|
||||
g_emu_window->MakeCurrent();
|
||||
|
||||
g_renderer = new RendererOpenGL();
|
||||
g_renderer->SetWindow(g_emu_window);
|
||||
g_renderer->Init();
|
||||
|
Loading…
Reference in New Issue
Block a user