summaryrefslogtreecommitdiffstats
path: root/examples/qt3d
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2017-04-25 08:30:38 +0200
committerPaul Lemire <paul.lemire@kdab.com>2017-04-25 09:41:57 +0000
commit85f2562428de462ad05516c754956d65faae7b78 (patch)
treef3a88db46bc596f6168eeb1a3853205b11e8f596 /examples/qt3d
parent21d891722cbaa18f6352804d5b4a3d4cf6911c41 (diff)
simplecustommaterial: add GL2 shader variant
Change-Id: Ie55724be1872f98660093b0fd5cea54d7e0eae11 Task-number: QTBUG-60289 Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Diffstat (limited to 'examples/qt3d')
-rw-r--r--examples/qt3d/simplecustommaterial/SimpleMaterial.qml13
-rw-r--r--examples/qt3d/simplecustommaterial/main.cpp19
2 files changed, 32 insertions, 0 deletions
diff --git a/examples/qt3d/simplecustommaterial/SimpleMaterial.qml b/examples/qt3d/simplecustommaterial/SimpleMaterial.qml
index 0ad045e25..22cc028b0 100644
--- a/examples/qt3d/simplecustommaterial/SimpleMaterial.qml
+++ b/examples/qt3d/simplecustommaterial/SimpleMaterial.qml
@@ -99,6 +99,19 @@ Material {
shaderProgram: gl3Shader
}
},
+ // OpenGL 2.0
+ Technique {
+ filterKeys: [forward]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.NoProfile
+ majorVersion: 2
+ minorVersion: 0
+ }
+ renderPasses: RenderPass {
+ shaderProgram: es2Shader
+ }
+ },
// ES 2.0
Technique {
filterKeys: [forward]
diff --git a/examples/qt3d/simplecustommaterial/main.cpp b/examples/qt3d/simplecustommaterial/main.cpp
index 392fe50ee..d841e7d19 100644
--- a/examples/qt3d/simplecustommaterial/main.cpp
+++ b/examples/qt3d/simplecustommaterial/main.cpp
@@ -50,9 +50,28 @@
#include <QGuiApplication>
#include <QQuickView>
+#include <QOpenGLContext>
+
+void setSurfaceFormat()
+{
+ QSurfaceFormat format;
+#ifdef QT_OPENGL_ES_2
+ format.setRenderableType(QSurfaceFormat::OpenGLES);
+#else
+ if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) {
+ format.setVersion(4, 3);
+ format.setProfile(QSurfaceFormat::CoreProfile);
+ }
+#endif
+ format.setDepthBufferSize(24);
+ format.setSamples(4);
+ format.setStencilBufferSize(8);
+ QSurfaceFormat::setDefaultFormat(format);
+}
int main(int argc, char **argv)
{
+ setSurfaceFormat();
QGuiApplication app(argc, argv);
QQuickView view;