From f8cdbf3e398b2df2b665ceb23ad7dca6010daa24 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Fri, 20 Aug 2021 13:32:03 +0100 Subject: [PATCH] Force ANGLE GPU acceleration on Windows .. we know that opengl drivers for windows can be sketchy, so rather than not use opengl at all we insist on ANGLE at startup. .. this is experimental and has been included as a single commit in the hope it will remain, but may be reverted if there are significant issues. --- src/Core/main.cpp | 6 ++++++ src/Gui/ChartSpace.cpp | 21 ++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/Core/main.cpp b/src/Core/main.cpp index a57816569..97fb34d0c 100644 --- a/src/Core/main.cpp +++ b/src/Core/main.cpp @@ -414,6 +414,12 @@ main(int argc, char *argv[]) // what to do. We may add our own error handler later. gsl_set_error_handler_off(); +#ifdef Q_OS_WIN + // windows we use ANGLE for opengl on top of DirectX + // it avoids issues with bad graphics drivers + QCoreApplication::setAttribute(Qt::AA_UseOpenGLES); +#endif + // create the application -- only ever ONE regardless of restarts application = new QApplication(argc, argv); //XXXIdleEventFilter idleFilter; diff --git a/src/Gui/ChartSpace.cpp b/src/Gui/ChartSpace.cpp index 4ffe9e7b7..f31ebf8f5 100644 --- a/src/Gui/ChartSpace.cpp +++ b/src/Gui/ChartSpace.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2020 Mark Liversedge (liversedge@gmail.com) * * This program is free software; you can redistribute it and/or modify it @@ -50,14 +50,21 @@ ChartSpace::ChartSpace(Context *context, int scope, GcWindow *window) : scene = new QGraphicsScene(this); view = new QGraphicsView(this); -#ifdef Q_OS_LINUX + // hardware acceleration is important for this widget +#if defined(Q_OS_LINUX) // if we have OpenGL and its 2.0 or higher, lets use it. // this is pretty much any GPU since 2004 and keeps Qt happy. - // we only do this on Linux since Windows and MacOS have issues - // on Windows AMD Radeon drivers are dreadful and on MacOS - // OpenGL support is deprecated and users have reported rendering - // issues when this is enabled. - if (gl_major >= 2.0) view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers | QGL::DirectRendering))); + // we only do this on Linux + //if (gl_major >= 2.0) view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers | QGL::DirectRendering))); + if (gl_major >= 2.0) view->setViewport(new QGLWidget()); +#endif +#if defined(Q_OS_WIN) + // on windows we always use OpenGL since we have forced + // ANGLE in main.cpp to implement opengl on top of directx + view->setViewport(new QGLWidget()); +#endif +#if defined (Q_OS_MACOS) + // we have no options right now, it sucks #endif view->viewport()->setAttribute(Qt::WA_AcceptTouchEvents, false); // stops it stealing focus on mouseover