summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2021-01-05 09:15:10 +0100
committerPaul Lemire <paul.lemire@kdab.com>2021-01-07 07:06:56 +0100
commitd7e9d76bf39b90bd2d7942d4dfab2a0cbb2966b6 (patch)
treec7a6dde3e75fd5f781391d3a5ea6426cf229d21e
parentddcff225991192bb596e05ec09f7c1a9e6872c7a (diff)
Qt3DWindow::setupWindowSurface set QT3D_RENDERER env variable if unset
So that anything relying on that env variable to detect the Qt3D rendering backend gets a valid value. Pick-to: 6.0 Change-Id: I291ec03720fd6127900f43888a7e40ab382a075a Reviewed-by: Mike Krus <mike.krus@kdab.com>
-rw-r--r--src/extras/defaults/qt3dwindow.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/extras/defaults/qt3dwindow.cpp b/src/extras/defaults/qt3dwindow.cpp
index ec0bcb2f0..1ac1d6b60 100644
--- a/src/extras/defaults/qt3dwindow.cpp
+++ b/src/extras/defaults/qt3dwindow.cpp
@@ -302,16 +302,26 @@ void setupWindowSurface(QWindow *window, Qt3DRender::API api) noexcept
default:
break;
}
+
+ // Default to using RHI backend is not specified We want to set the
+ // variable to ensure any 3rd party relying on it to detect which rendering
+ // backend is in use will get a valid value.
+ if (qEnvironmentVariableIsEmpty("QT3D_RENDERER"))
+ qputenv("QT3D_RENDERER", "rhi");
+
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
+ const QByteArray renderingBackend = qgetenv("QT3D_RENDERER");
+ const bool usesRHI = renderingBackend.isEmpty() || renderingBackend == QByteArrayLiteral("rhi");
+ if (!usesRHI) {
#if QT_CONFIG(opengles2)
- format.setRenderableType(QSurfaceFormat::OpenGLES);
+ format.setRenderableType(QSurfaceFormat::OpenGLES);
#else
- if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) {
- format.setVersion(4, 3);
- format.setProfile(QSurfaceFormat::CoreProfile);
- } else
+ if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) {
+ format.setVersion(4, 3);
+ format.setProfile(QSurfaceFormat::CoreProfile);
+ }
#endif
- if (!userRequestedApi.isEmpty()) {
+ } else {
// This is used for RHI
format.setVersion(1, 0);
}