Minor Qt cleanup, force OpenGL since we don't yet support Vulkan in Qt

This commit is contained in:
Henrik Rydgård 2018-02-08 11:19:48 +01:00
parent 3ff69d73ff
commit 20eb566665
2 changed files with 24 additions and 17 deletions

View file

@ -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

View file

@ -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() {}