mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 23:57:13 +02:00
Force Qt to use ANGLE when in GLES mode on Windows
This commit is contained in:
parent
1da29862e7
commit
d10d7026c5
3 changed files with 26 additions and 8 deletions
|
@ -41,17 +41,22 @@ else()
|
||||||
option(BUILD_TESTS "Build tests" ON)
|
option(BUILD_TESTS "Build tests" ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(DISABLE_QML "Disable QML" OFF)
|
if (ANDROID)
|
||||||
|
option(USE_GLES "Use OpenGL ES" ON)
|
||||||
|
set(PLATFORM_QT_COMPONENTS AndroidExtras WebView)
|
||||||
|
else ()
|
||||||
|
option(USE_GLES "Use OpenGL ES" OFF)
|
||||||
|
set(PLATFORM_QT_COMPONENTS WebEngine WebEngineWidgets)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (USE_GLES AND (NOT ANDROID))
|
||||||
|
option(DISABLE_QML "Disable QML" ON)
|
||||||
|
else()
|
||||||
|
option(DISABLE_QML "Disable QML" OFF)
|
||||||
|
endif()
|
||||||
option(DISABLE_KTX_CACHE "Disable KTX Cache" OFF)
|
option(DISABLE_KTX_CACHE "Disable KTX Cache" OFF)
|
||||||
|
|
||||||
|
|
||||||
if (ANDROID)
|
|
||||||
option(USE_GLES "Use OpenGL ES" ON)
|
|
||||||
set(PLATFORM_QT_COMPONENTS AndroidExtras WebView)
|
|
||||||
else ()
|
|
||||||
option(USE_GLES "Use OpenGL ES" OFF)
|
|
||||||
set(PLATFORM_QT_COMPONENTS WebEngine WebEngineWidgets)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
set(PLATFORM_QT_GL OpenGL)
|
set(PLATFORM_QT_GL OpenGL)
|
||||||
|
|
||||||
|
|
|
@ -766,8 +766,10 @@ OverlayID _keyboardFocusHighlightID{ UNKNOWN_OVERLAY_ID };
|
||||||
//
|
//
|
||||||
// So instead we create a new offscreen context to share with the QGLWidget,
|
// So instead we create a new offscreen context to share with the QGLWidget,
|
||||||
// and manually set THAT to be the shared context for the Chromium helper
|
// and manually set THAT to be the shared context for the Chromium helper
|
||||||
|
#if !defined(DISABLE_QML)
|
||||||
OffscreenGLCanvas* _chromiumShareContext { nullptr };
|
OffscreenGLCanvas* _chromiumShareContext { nullptr };
|
||||||
Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context);
|
Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context);
|
||||||
|
#endif
|
||||||
|
|
||||||
Setting::Handle<int> sessionRunTime{ "sessionRunTime", 0 };
|
Setting::Handle<int> sessionRunTime{ "sessionRunTime", 0 };
|
||||||
|
|
||||||
|
@ -2225,6 +2227,8 @@ void Application::initializeGL() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_glWidget->makeCurrent();
|
_glWidget->makeCurrent();
|
||||||
|
|
||||||
|
#if !defined(DISABLE_QML)
|
||||||
if (!nsightActive()) {
|
if (!nsightActive()) {
|
||||||
_chromiumShareContext = new OffscreenGLCanvas();
|
_chromiumShareContext = new OffscreenGLCanvas();
|
||||||
_chromiumShareContext->setObjectName("ChromiumShareContext");
|
_chromiumShareContext->setObjectName("ChromiumShareContext");
|
||||||
|
@ -2232,6 +2236,7 @@ void Application::initializeGL() {
|
||||||
_chromiumShareContext->makeCurrent();
|
_chromiumShareContext->makeCurrent();
|
||||||
qt_gl_set_global_share_context(_chromiumShareContext->getContext());
|
qt_gl_set_global_share_context(_chromiumShareContext->getContext());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
_glWidget->makeCurrent();
|
_glWidget->makeCurrent();
|
||||||
gpu::Context::init<gpu::gl::GLBackend>();
|
gpu::Context::init<gpu::gl::GLBackend>();
|
||||||
|
|
|
@ -52,6 +52,14 @@ int main(int argc, const char* argv[]) {
|
||||||
QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
|
QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(USE_GLES) && defined(Q_OS_WIN)
|
||||||
|
// When using GLES on Windows, we can't create normal GL context in Qt, so
|
||||||
|
// we force Qt to use angle. This will cause the QML to be unable to be used
|
||||||
|
// in the output window, so QML should be disabled.
|
||||||
|
qputenv("QT_ANGLE_PLATFORM", "d3d11");
|
||||||
|
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
|
||||||
|
#endif
|
||||||
|
|
||||||
disableQtBearerPoll(); // Fixes wifi ping spikes
|
disableQtBearerPoll(); // Fixes wifi ping spikes
|
||||||
|
|
||||||
QElapsedTimer startupTime;
|
QElapsedTimer startupTime;
|
||||||
|
|
Loading…
Reference in a new issue