Frontend: Don't call DoneCurrent if the context isnt already current

This commit is contained in:
James Rowe 2020-03-30 14:52:46 -06:00
parent cf9c94d401
commit f1da3ec584
2 changed files with 13 additions and 2 deletions

View File

@ -141,7 +141,7 @@ public:
} }
~OpenGLSharedContext() { ~OpenGLSharedContext() {
context->doneCurrent(); DoneCurrent();
} }
void SwapBuffers() override { void SwapBuffers() override {
@ -156,6 +156,9 @@ public:
} }
void DoneCurrent() override { void DoneCurrent() override {
if (!is_current) {
return;
}
context->doneCurrent(); context->doneCurrent();
is_current = false; is_current = false;
} }

View File

@ -37,16 +37,24 @@ public:
} }
void MakeCurrent() override { void MakeCurrent() override {
SDL_GL_MakeCurrent(window, context); if (is_current) {
return;
}
is_current = SDL_GL_MakeCurrent(window, context) == 0;
} }
void DoneCurrent() override { void DoneCurrent() override {
if (!is_current) {
return;
}
SDL_GL_MakeCurrent(window, nullptr); SDL_GL_MakeCurrent(window, nullptr);
is_current = false;
} }
private: private:
SDL_Window* window; SDL_Window* window;
SDL_GLContext context; SDL_GLContext context;
bool is_current = false;
}; };
bool EmuWindow_SDL2_GL::SupportsRequiredGLExtensions() { bool EmuWindow_SDL2_GL::SupportsRequiredGLExtensions() {