From 85f2562428de462ad05516c754956d65faae7b78 Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Tue, 25 Apr 2017 08:30:38 +0200 Subject: simplecustommaterial: add GL2 shader variant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie55724be1872f98660093b0fd5cea54d7e0eae11 Task-number: QTBUG-60289 Reviewed-by: Antti Määttä --- examples/qt3d/simplecustommaterial/SimpleMaterial.qml | 13 +++++++++++++ examples/qt3d/simplecustommaterial/main.cpp | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'examples/qt3d/simplecustommaterial') 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 #include +#include + +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; -- cgit v1.2.3