aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickopenglshadereffect.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2016-06-29 17:53:13 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2016-07-01 11:36:58 +0000
commitda839643397dda062cf7371e01fc1c990b7cf7c3 (patch)
treec84bc317ee0aab06e762a5466274787190aa4180 /src/quick/items/qquickopenglshadereffect.cpp
parent023170b8276659118fd28d787597d749f80501e9 (diff)
Add a core profile file selector to OpenGL ShaderEffect
Similarly to what we do with "hlsl" in the D3D12 backend, we can use "glslcore" to provide a file-based alternative to the GraphcsInfo or OpenGLInfo-based conditions in the fragmentShader and vertexShader properties. This is particularly useful in a few places inside Qt, for example Quick Controls, that have to cater to all possiblities. Change-Id: I5d89e7b1534afbc323a663869bab7796bd1a337d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/items/qquickopenglshadereffect.cpp')
-rw-r--r--src/quick/items/qquickopenglshadereffect.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/quick/items/qquickopenglshadereffect.cpp b/src/quick/items/qquickopenglshadereffect.cpp
index f65062ae38..b77a7830ff 100644
--- a/src/quick/items/qquickopenglshadereffect.cpp
+++ b/src/quick/items/qquickopenglshadereffect.cpp
@@ -53,6 +53,7 @@
#include <QtQml/qqmlfile.h>
#include <QtCore/qsignalmapper.h>
+#include <QtCore/qfileselector.h>
QT_BEGIN_NAMESPACE
@@ -325,7 +326,16 @@ void QQuickOpenGLShaderEffectCommon::updateShader(QQuickItem *item, Key::ShaderT
// A qrc or file URL means the shader source is to be read from the specified file.
QUrl srcUrl(QString::fromUtf8(source.sourceCode[shaderType]));
if (!srcUrl.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) || srcUrl.isLocalFile()) {
- const QString fn = QQmlFile::urlToLocalFileOrQrc(srcUrl);
+ if (!fileSelector) {
+ fileSelector = new QFileSelector(item);
+ // There may not be an OpenGL context accessible here. So rely on
+ // the window's requestedFormat().
+ if (item->window()
+ && item->window()->requestedFormat().profile() == QSurfaceFormat::CoreProfile) {
+ fileSelector->setExtraSelectors(QStringList() << QStringLiteral("glslcore"));
+ }
+ }
+ const QString fn = fileSelector->select(QQmlFile::urlToLocalFileOrQrc(srcUrl));
QFile f(fn);
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
source.sourceCode[shaderType] = f.readAll();