diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-03-20 15:47:22 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-24 22:27:21 +0100 |
commit | 76dd99c448ae69cb12a0465facc5dd743b94e624 (patch) | |
tree | 785288589e8645a42be240960e75a6ff718faf64 /src/controls/Private/FastGlow.qml | |
parent | 51156e412b2f91dbbf8c0b6055e6ab4c29370d8a (diff) | |
download | qtquickcontrols-76dd99c448ae69cb12a0465facc5dd743b94e624.tar.gz |
Fix shaders for OpenGL core profiles
Add also a --coreprofile command-line parameter to the gallery and
systemdialogs examples to allow testing Quick Controls with an OpenGL 3.2+
core profile.
This depends on the new features introduced to qtdeclarative in
I75a47182 and I41b513e9.
Change-Id: I408263a108a71df221943915849a4c3e18e0d3e4
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/controls/Private/FastGlow.qml')
-rw-r--r-- | src/controls/Private/FastGlow.qml | 71 |
1 files changed, 67 insertions, 4 deletions
diff --git a/src/controls/Private/FastGlow.qml b/src/controls/Private/FastGlow.qml index f4bd2c74..e008dad4 100644 --- a/src/controls/Private/FastGlow.qml +++ b/src/controls/Private/FastGlow.qml @@ -64,7 +64,25 @@ Item { hideSource: visible } - property string __internalBlurVertexShader: " + property string __internalBlurVertexShader: rootItem.window.glslIsCoreProfile ? "#version 150 + in vec4 qt_Vertex; + in vec2 qt_MultiTexCoord0; + uniform mat4 qt_Matrix; + uniform float yStep; + uniform float xStep; + out vec2 qt_TexCoord0; + out vec2 qt_TexCoord1; + out vec2 qt_TexCoord2; + out vec2 qt_TexCoord3; + + void main() { + qt_TexCoord0 = vec2(qt_MultiTexCoord0.x + xStep, qt_MultiTexCoord0.y + yStep * 0.36); + qt_TexCoord1 = vec2(qt_MultiTexCoord0.x + xStep * 0.36, qt_MultiTexCoord0.y - yStep); + qt_TexCoord2 = vec2(qt_MultiTexCoord0.x - xStep * 0.36, qt_MultiTexCoord0.y + yStep); + qt_TexCoord3 = vec2(qt_MultiTexCoord0.x - xStep, qt_MultiTexCoord0.y - yStep * 0.36); + gl_Position = qt_Matrix * qt_Vertex; + } + " : " attribute highp vec4 qt_Vertex; attribute highp vec2 qt_MultiTexCoord0; uniform highp mat4 qt_Matrix; @@ -83,8 +101,23 @@ Item { gl_Position = qt_Matrix * qt_Vertex; } " + property string __internalBlurFragmentShader: rootItem.window.glslIsCoreProfile ? "#version 150 + uniform sampler2D source; + uniform float qt_Opacity; + in vec2 qt_TexCoord0; + in vec2 qt_TexCoord1; + in vec2 qt_TexCoord2; + in vec2 qt_TexCoord3; + out vec4 fragColor; - property string __internalBlurFragmentShader: " + void main() { + vec4 sourceColor = (texture(source, qt_TexCoord0) + + texture(source, qt_TexCoord1) + + texture(source, qt_TexCoord2) + + texture(source, qt_TexCoord3)) * 0.25; + fragColor = sourceColor * qt_Opacity; + } + " : " uniform lowp sampler2D source; uniform lowp float qt_Opacity; varying highp vec2 qt_TexCoord0; @@ -99,7 +132,7 @@ Item { texture2D(source, qt_TexCoord3)) * 0.25; gl_FragColor = sourceColor * qt_Opacity; } - " + " ShaderEffect { id: level0 @@ -359,7 +392,37 @@ Item { onLodChanged: calculateWeights() - fragmentShader: " + fragmentShader: rootItem.window.glslIsCoreProfile ? "#version 150 + uniform sampler2D source1; + uniform sampler2D source2; + uniform sampler2D source3; + uniform sampler2D source4; + uniform sampler2D source5; + uniform float weight1; + uniform float weight2; + uniform float weight3; + uniform float weight4; + uniform float weight5; + uniform vec4 color; + uniform float spread; + uniform float qt_Opacity; + in vec2 qt_TexCoord0; + out vec4 fragColor; + + float linearstep(float e0, float e1, float x) { + return clamp((x - e0) / (e1 - e0), 0.0, 1.0); + } + + void main() { + vec4 sourceColor = texture(source1, qt_TexCoord0) * weight1; + sourceColor += texture(source2, qt_TexCoord0) * weight2; + sourceColor += texture(source3, qt_TexCoord0) * weight3; + sourceColor += texture(source4, qt_TexCoord0) * weight4; + sourceColor += texture(source5, qt_TexCoord0) * weight5; + sourceColor = mix(vec4(0), color, linearstep(0.0, spread, sourceColor.a)); + fragColor = sourceColor * qt_Opacity; + } + " : " uniform lowp sampler2D source1; uniform lowp sampler2D source2; uniform lowp sampler2D source3; |