summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-03-14 10:49:20 +0100
committerLiang Qi <liang.qi@qt.io>2017-03-14 10:52:24 +0100
commit0c034a649f61019c16aba479fe79d20dde41f2f2 (patch)
tree54545862591044b65e618989805945bceb0b3ea5 /examples
parent2162f01111d21d0ce66ceb8be290b0a13653e691 (diff)
parentdf40b1115db600e8de1c4774476fa30956a34fd9 (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: src/widgets/widgets/qpushbutton.cpp Change-Id: I615de00e6e64540c50f658d4d8ab3e002d701a81
Diffstat (limited to 'examples')
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/main.cpp14
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp14
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/mainwindow.h14
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp14
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.h14
-rw-r--r--examples/opengl/computegles31/glwindow.cpp79
-rw-r--r--examples/opengl/computegles31/glwindow.h15
-rw-r--r--examples/opengl/computegles31/main.cpp78
8 files changed, 178 insertions, 64 deletions
diff --git a/examples/corelib/mimetypes/mimetypebrowser/main.cpp b/examples/corelib/mimetypes/mimetypebrowser/main.cpp
index daa92a2344..f4462df411 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/main.cpp
+++ b/examples/corelib/mimetypes/mimetypebrowser/main.cpp
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
diff --git a/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp b/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp
index edd48021f3..1d36b7e5ef 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp
+++ b/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
diff --git a/examples/corelib/mimetypes/mimetypebrowser/mainwindow.h b/examples/corelib/mimetypes/mimetypebrowser/mainwindow.h
index 11b1f004a0..978cdec4f4 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/mainwindow.h
+++ b/examples/corelib/mimetypes/mimetypebrowser/mainwindow.h
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
diff --git a/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp b/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp
index 46e603621a..ee83de092d 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp
+++ b/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
diff --git a/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.h b/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.h
index 0656e64e8f..6c537f4001 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.h
+++ b/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.h
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
diff --git a/examples/opengl/computegles31/glwindow.cpp b/examples/opengl/computegles31/glwindow.cpp
index d2cea169a1..7a14cba66d 100644
--- a/examples/opengl/computegles31/glwindow.cpp
+++ b/examples/opengl/computegles31/glwindow.cpp
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -44,7 +54,7 @@
#include <QOpenGLContext>
#include <QOpenGLFunctions>
#include <QOpenGLExtraFunctions>
-//#include <QtGui/qopenglext.h>
+#include <QOpenGLVertexArrayObject>
#include <QtGui/qopengl.h>
#include <QDebug>
#include <QTimer>
@@ -70,7 +80,8 @@ GLWindow::GLWindow()
m_shaderComputeV(0),
m_shaderComputeH(0),
m_blurRadius(0.0f),
- m_animate(true)
+ m_animate(true),
+ m_vao(0)
{
const float animationStart = 0.0;
const float animationEnd = 10.0;
@@ -106,6 +117,7 @@ GLWindow::~GLWindow()
delete m_animationGroup;
delete m_animationForward;
delete m_animationBackward;
+ delete m_vao;
}
void GLWindow::setBlurRadius(float blurRadius)
@@ -168,19 +180,21 @@ static const char *fsDisplaySource =
"}\n";
static const char *csComputeSourceV =
- //"#extension GL_EXT_gpu_shader5 : require \n"
"#define COMPUTEPATCHSIZE 32 \n"
"#define IMGFMT rgba8 \n"
"layout (local_size_x = COMPUTEPATCHSIZE, local_size_y = COMPUTEPATCHSIZE) in;\n"
- "layout(binding=0, IMGFMT) uniform highp image2D inputImage; // Use a sampler to improve performance \n"
- "layout(binding=1, IMGFMT) uniform highp image2D resultImage;\n"
+ "layout(binding=0, IMGFMT) uniform readonly highp image2D inputImage; // Use a sampler to improve performance \n"
+ "layout(binding=1, IMGFMT) uniform writeonly highp image2D resultImage;\n"
"uniform int radius;\n"
"const float cutoff = 2.2;\n"
- "float sigma = clamp(float(radius) / cutoff,0.02,100.0);\n" // Const initialization with dynamically uniform expressions doesn't work in GLES
- "float expFactor = 1.0 / (2.0 * sigma * sigma);\n" // Same here
- "float gaussian(float distance) {\n"
- " return exp( -(distance * distance) * expFactor);\n"
+ "float expFactor() { // a function, otherwise MESA produces error: initializer of global variable `expFactor' must be a constant expression\n"
+ " float sigma = clamp(float(radius) / cutoff,0.02,100.0);\n"
+ " return 1.0 / (2.0 * sigma * sigma);\n"
+ "}\n"
+
+ "float gaussian(float distance, float expfactor) {\n"
+ " return exp( -(distance * distance) * expfactor);\n"
"}\n"
"void main() {\n"
@@ -194,31 +208,34 @@ static const char *csComputeSourceV =
" int right = clamp(x + radius, 0, imgSize.x - 1);\n"
" int top = clamp(y - radius, 0, imgSize.y - 1);\n"
" int bottom = clamp(y + radius, 0, imgSize.y - 1);\n"
+ " float expfactor = expFactor();\n"
" for (int iY = top; iY <= bottom; iY++) {\n"
" float dy = float(abs(iY - y));\n"
" vec4 imgValue = imageLoad(inputImage, ivec2(x,iY));\n"
- " float weight = gaussian(dy);\n"
+ " float weight = gaussian(dy, expfactor);\n"
" sumWeights += weight;\n"
" sumPixels += (imgValue * weight);\n"
" }\n"
" sumPixels /= sumWeights;\n"
- " imageStore(resultImage, ivec2(x,y), sumPixels);"
+ " imageStore(resultImage, ivec2(x,y), sumPixels);\n"
"}\n";
static const char *csComputeSourceH =
- //"#extension GL_EXT_gpu_shader5 : require \n"
"#define COMPUTEPATCHSIZE 32 \n"
"#define IMGFMT rgba8 \n"
"layout (local_size_x = COMPUTEPATCHSIZE, local_size_y = COMPUTEPATCHSIZE) in;\n"
- "layout(binding=0, IMGFMT) uniform highp image2D inputImage; // Use a sampler to improve performance \n"
- "layout(binding=1, IMGFMT) uniform highp image2D resultImage;\n"
+ "layout(binding=0, IMGFMT) uniform readonly highp image2D inputImage; // Use a sampler to improve performance \n"
+ "layout(binding=1, IMGFMT) uniform writeonly highp image2D resultImage;\n"
"uniform int radius;\n"
"const float cutoff = 2.2;\n"
- "float sigma = clamp(float(radius) / cutoff,0.02,100.0);\n"
- "float expFactor = 1.0 / (2.0 * sigma * sigma);\n"
- "float gaussian(float distance) {\n"
- " return exp( -(distance * distance) * expFactor);\n"
+ "float expFactor() { // a function, otherwise MESA produces error: initializer of global variable `expFactor' must be a constant expression\n"
+ " float sigma = clamp(float(radius) / cutoff,0.02,100.0);\n"
+ " return 1.0 / (2.0 * sigma * sigma);\n"
+ "}\n"
+
+ "float gaussian(float distance, float expfactor) {\n"
+ " return exp( -(distance * distance) * expfactor);\n"
"}\n"
"void main() {\n"
@@ -232,15 +249,16 @@ static const char *csComputeSourceH =
" int right = clamp(x + radius, 0, imgSize.x - 1);\n"
" int top = clamp(y - radius, 0, imgSize.y - 1);\n"
" int bottom = clamp(y + radius, 0, imgSize.y - 1);\n"
- " for (int iX = left; iX <= right; iX++) {\n"
+ " float expfactor = expFactor();\n"
+ " for (int iX = left; iX <= right; iX++) {\n"
" float dx = float(abs(iX - x));\n"
" vec4 imgValue = imageLoad(inputImage, ivec2(iX,y));\n"
- " float weight = gaussian(dx);\n"
+ " float weight = gaussian(dx, expfactor);\n"
" sumWeights += weight;\n"
" sumPixels += (imgValue * weight);\n"
- " }\n"
+ " }\n"
" sumPixels /= sumWeights;\n"
- " imageStore(resultImage, ivec2(x,y), sumPixels);"
+ " imageStore(resultImage, ivec2(x,y), sumPixels);\n"
"}\n";
@@ -252,7 +270,7 @@ QByteArray versionedShaderCode(const char *src)
if (QOpenGLContext::currentContext()->isOpenGLES())
versionedSrc.append(QByteArrayLiteral("#version 310 es\n"));
else
- versionedSrc.append(QByteArrayLiteral("#version 430\n"));
+ versionedSrc.append(QByteArrayLiteral("#version 430 core\n"));
versionedSrc.append(src);
return versionedSrc;
@@ -305,7 +323,6 @@ void GLWindow::initializeGL()
<< ctx->format().minorVersion()
<< ((ctx->format().renderableType() == QSurfaceFormat::OpenGLES) ? (" GLES") : (" GL"))
<< " context";
- //QOpenGLFunctions *f = ctx->functions();
if (m_texImageInput) {
delete m_texImageInput;
@@ -363,6 +380,10 @@ void GLWindow::initializeGL()
m_shaderComputeH = new QOpenGLShaderProgram;
m_shaderComputeH->addShaderFromSourceCode(QOpenGLShader::Compute, versionedShaderCode(csComputeSourceH));
m_shaderComputeH->link();
+
+ // Create a VAO. Not strictly required for ES 3, but it is for plain OpenGL core context.
+ m_vao = new QOpenGLVertexArrayObject;
+ m_vao->create();
}
void GLWindow::resizeGL(int w, int h)
@@ -411,13 +432,15 @@ void GLWindow::paintGL()
// Display processed image
f->glClearColor(0, 0, 0, 1);
f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- m_texImageProcessed->bind(GL_TEXTURE0);
+ m_texImageProcessed->bind(0);
m_shaderDisplay->bind();
m_shaderDisplay->setUniformValue("matProjection",m_proj);
m_shaderDisplay->setUniformValue("imageRatio",m_quadSize);
m_shaderDisplay->setUniformValue("samImage",0);
+ m_vao->bind();
f->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ m_vao->release();
m_shaderDisplay->release();
- m_texImageProcessed->release(GL_TEXTURE0);
+ m_texImageProcessed->release(0);
}
diff --git a/examples/opengl/computegles31/glwindow.h b/examples/opengl/computegles31/glwindow.h
index 15ece01780..877f7b732e 100644
--- a/examples/opengl/computegles31/glwindow.h
+++ b/examples/opengl/computegles31/glwindow.h
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -94,6 +104,7 @@ private:
int m_blurRadius;
bool m_animate;
+ QOpenGLVertexArrayObject *m_vao;
};
#endif
diff --git a/examples/opengl/computegles31/main.cpp b/examples/opengl/computegles31/main.cpp
index ff2a1e622d..88f0f36115 100644
--- a/examples/opengl/computegles31/main.cpp
+++ b/examples/opengl/computegles31/main.cpp
@@ -1,12 +1,22 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -46,15 +56,17 @@
#include <QPair>
#include "glwindow.h"
-bool OGLSupports(int major, int minor, bool gles = false)
+bool OGLSupports(int major, int minor, bool gles = false, QSurfaceFormat::OpenGLContextProfile profile = QSurfaceFormat::NoProfile)
{
QOpenGLContext ctx;
QSurfaceFormat fmt;
fmt.setVersion(major, minor);
- if (gles)
+ if (gles) {
fmt.setRenderableType(QSurfaceFormat::OpenGLES);
- else
+ } else {
fmt.setRenderableType(QSurfaceFormat::OpenGL);
+ fmt.setProfile(profile);
+ }
ctx.setFormat(fmt);
ctx.create();
@@ -68,6 +80,8 @@ bool OGLSupports(int major, int minor, bool gles = false)
if (ctxMajor < major) return false;
if (ctxMajor == major && ctxMinor < minor)
return false;
+ if (!gles && ctx.format().profile() != profile)
+ return false;
return true;
}
@@ -75,18 +89,34 @@ int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
- qDebug() << "Support for GL 2.0 "<<( OGLSupports(2,0) ? "yes" : "no");
- qDebug() << "Support for GL 2.1 "<<( OGLSupports(2,1) ? "yes" : "no");
- qDebug() << "Support for GL 3.0 "<<( OGLSupports(3,0) ? "yes" : "no");
- qDebug() << "Support for GL 3.1 "<<( OGLSupports(3,1) ? "yes" : "no");
- qDebug() << "Support for GL 3.2 "<<( OGLSupports(3,2) ? "yes" : "no");
- qDebug() << "Support for GL 3.3 "<<( OGLSupports(3,3) ? "yes" : "no");
- qDebug() << "Support for GL 4.0 "<<( OGLSupports(4,0) ? "yes" : "no");
- qDebug() << "Support for GL 4.1 "<<( OGLSupports(4,1) ? "yes" : "no");
- qDebug() << "Support for GL 4.2 "<<( OGLSupports(4,2) ? "yes" : "no");
- qDebug() << "Support for GL 4.3 "<<( OGLSupports(4,3) ? "yes" : "no");
- qDebug() << "Support for GL 4.4 "<<( OGLSupports(4,4) ? "yes" : "no");
- qDebug() << "Support for GL 4.5 "<<( OGLSupports(4,5) ? "yes" : "no");
+ qDebug() << "Support for GL 2.0 noprof "<<( OGLSupports(2,0,false) ? "yes" : "no");
+ qDebug() << "Support for GL 2.0 core "<<( OGLSupports(2,0,false, QSurfaceFormat::CoreProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 2.0 compat "<<( OGLSupports(2,0,false, QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 2.1 noprof "<<( OGLSupports(2,1,false) ? "yes" : "no");
+ qDebug() << "Support for GL 2.1 core "<<( OGLSupports(2,1,false, QSurfaceFormat::CoreProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 2.1 compat "<<( OGLSupports(2,1,false, QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 3.0 noprof "<<( OGLSupports(3,0,false) ? "yes" : "no");
+ qDebug() << "Support for GL 3.0 core "<<( OGLSupports(3,0,false, QSurfaceFormat::CoreProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 3.0 compat "<<( OGLSupports(3,0,false, QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 3.1 noprof "<<( OGLSupports(3,1,false) ? "yes" : "no");
+ qDebug() << "Support for GL 3.1 core "<<( OGLSupports(3,1,false, QSurfaceFormat::CoreProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 3.1 compat "<<( OGLSupports(3,1,false, QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 3.2 core "<<( OGLSupports(3,2,false,QSurfaceFormat::CoreProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 3.2 compat "<<( OGLSupports(3,2,false,QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 3.3 core "<<( OGLSupports(3,3,false,QSurfaceFormat::CoreProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 3.3 compat "<<( OGLSupports(3,3,false,QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 4.0 core "<<( OGLSupports(4,0,false,QSurfaceFormat::CoreProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 4.0 compat "<<( OGLSupports(4,0,false,QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 4.1 core "<<( OGLSupports(4,1,false,QSurfaceFormat::CoreProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 4.1 compat "<<( OGLSupports(4,1,false,QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 4.2 core "<<( OGLSupports(4,2,false,QSurfaceFormat::CoreProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 4.2 compat "<<( OGLSupports(4,2,false,QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 4.3 core "<<( OGLSupports(4,3,false,QSurfaceFormat::CoreProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 4.3 compat "<<( OGLSupports(4,3,false,QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 4.4 core "<<( OGLSupports(4,4,false,QSurfaceFormat::CoreProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 4.4 compat "<<( OGLSupports(4,4,false,QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 4.5 core "<<( OGLSupports(4,5,false,QSurfaceFormat::CoreProfile) ? "yes" : "no");
+ qDebug() << "Support for GL 4.5 compat "<<( OGLSupports(4,5,false,QSurfaceFormat::CompatibilityProfile) ? "yes" : "no");
qDebug() << "Support for GLES 2.0 "<<( OGLSupports(2,0,true) ? "yes" : "no");
qDebug() << "Support for GLES 3.0 "<<( OGLSupports(3,0,true) ? "yes" : "no");
qDebug() << "Support for GLES 3.1 "<<( OGLSupports(3,1,true) ? "yes" : "no");
@@ -95,16 +125,16 @@ int main(int argc, char *argv[])
QSurfaceFormat fmt;
fmt.setDepthBufferSize(24);
- // Request OpenGL 4.3 compatibility or OpenGL ES 3.1.
- if (OGLSupports(4,3)) {
- qDebug("Requesting 4.3 compatibility context");
- fmt.setVersion(4, 3);
- fmt.setRenderableType(QSurfaceFormat::OpenGL);
- fmt.setProfile(QSurfaceFormat::CompatibilityProfile);
- } else if (OGLSupports(3,1,true)) {
+ // Request OpenGL ES 3.1 context, as this is a GLES example. If not available, go for OpenGL 4.3 core.
+ if (OGLSupports(3,1,true)) {
qDebug("Requesting 3.1 GLES context");
fmt.setVersion(3, 1);
fmt.setRenderableType(QSurfaceFormat::OpenGLES);
+ } else if (OGLSupports(4,3,false,QSurfaceFormat::CoreProfile)) {
+ qDebug("Requesting 4.3 core context");
+ fmt.setVersion(4, 3);
+ fmt.setRenderableType(QSurfaceFormat::OpenGL);
+ fmt.setProfile(QSurfaceFormat::CoreProfile);
} else {
qWarning("Error: This system does not support OpenGL Compute Shaders! Exiting.");
return -1;