diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index 74d8be6b2d..c9a9ac53a5 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -364,24 +364,28 @@ bool MainUI::event(QEvent *e) return true; } -void MainUI::initializeGL() -{ +void MainUI::initializeGL() { + if (g_Config.iGPUBackend != (int)GPUBackend::OPENGL) { + ILOG("Only GL supported under Qt - switching."); + g_Config.iGPUBackend = (int)GPUBackend::OPENGL; + } + #ifndef USING_GLES2 // Some core profile drivers elide certain extensions from GL_EXTENSIONS/etc. // glewExperimental allows us to force GLEW to search for the pointers anyway. - if (gl_extensions.IsCoreContext) + if (gl_extensions.IsCoreContext) { glewExperimental = true; + } glewInit(); // Unfortunately, glew will generate an invalid enum error, ignore. - if (gl_extensions.IsCoreContext) + if (gl_extensions.IsCoreContext) { glGetError(); + } #endif - ILOG("Initializing graphics context"); - - // OpenGL uses a background thread to do the main processing and only renders on the gl thread. - graphicsContext = new QtDummyGraphicsContext(); - if (g_Config.iGPUBackend == (int)GPUBackend::OPENGL) { + // OpenGL uses a background thread to do the main processing and only renders on the gl thread. + ILOG("Initializing GL graphics context"); + graphicsContext = new QtGLGraphicsContext(); ILOG("Using thread, starting emu thread"); EmuThreadStart(); } else { @@ -390,8 +394,7 @@ void MainUI::initializeGL() graphicsContext->ThreadStart(); } -void MainUI::paintGL() -{ +void MainUI::paintGL() { #ifdef SDL SDL_PumpEvents(); #endif diff --git a/Qt/QtMain.h b/Qt/QtMain.h index cc39d5802b..404e50439e 100644 --- a/Qt/QtMain.h +++ b/Qt/QtMain.h @@ -44,9 +44,9 @@ QTM_USE_NAMESPACE // Input void SimulateGamepad(); -class QtDummyGraphicsContext : public DummyGraphicsContext { +class QtGLGraphicsContext : public GraphicsContext { public: - QtDummyGraphicsContext() { + QtGLGraphicsContext() { CheckGLExtensions(); draw_ = Draw::T3DCreateGLContext(); SetGPUBackend(GPUBackend::OPENGL); @@ -55,12 +55,17 @@ public: assert(success); } - ~QtDummyGraphicsContext() { + ~QtGLGraphicsContext() { delete draw_; draw_ = nullptr; renderManager_ = nullptr; } + void Shutdown() override {} + void SwapInterval(int interval) override {} + void SwapBuffers() override {} + void Resize() override {} + Draw::DrawContext *GetDrawContext() override { return draw_; } @@ -123,7 +128,7 @@ protected: void EmuThreadJoin(); private: - QtDummyGraphicsContext *graphicsContext; + QtGLGraphicsContext *graphicsContext; float xscale, yscale; #if defined(MOBILE_DEVICE) @@ -139,8 +144,7 @@ extern MainUI* emugl; #ifndef SDL // Audio -class MainAudio: public QObject -{ +class MainAudio : public QObject { Q_OBJECT public: MainAudio() {}