From da839643397dda062cf7371e01fc1c990b7cf7c3 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 29 Jun 2016 17:53:13 +0200 Subject: 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 --- src/quick/items/qquickopenglshadereffect.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/quick/items/qquickopenglshadereffect.cpp') 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 #include +#include 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(); -- cgit v1.2.3