Skip to content

Commit 38956a5

Browse files
committed
Port {Circular,}Spinner fragmentShader to Qt6 (qsb)
1 parent f4008aa commit 38956a5

File tree

5 files changed

+31
-29
lines changed

5 files changed

+31
-29
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.6.0)
1+
cmake_minimum_required(VERSION 3.7.0)
22

33
project(qml-asteroid
44
VERSION 2.0.0

src/controls/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ qt_add_resources(asteroidcontrolsplugin "asteroidcontrolsplugin_qrc"
4444
"qml/TextField.qml"
4545
)
4646

47+
if (QT_MAJOR_VERSION GREATER_EQUAL 6)
48+
find_package(Qt6 COMPONENTS ShaderTools)
49+
qt6_add_shaders(asteroidcontrolsplugin "asteroidcontrolsplugin_shaders"
50+
#GLSL "300es,330" # FIXME: drop?
51+
BATCHABLE
52+
PRECOMPILE
53+
OPTIMIZED
54+
PREFIX
55+
"/org/asteroid/controls/"
56+
FILES
57+
"qml/Spinner.frag"
58+
)
59+
endif()
60+
4761
set(controls
4862
Application
4963
BorderGestureArea

src/controls/qml/CircularSpinner.qml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,6 @@ PathView {
9393

9494
layer.enabled: true
9595
layer.effect: ShaderEffect {
96-
fragmentShader: "
97-
precision mediump float;
98-
varying highp vec2 qt_TexCoord0;
99-
uniform sampler2D source;
100-
void main(void)
101-
{
102-
vec4 sourceColor = texture2D(source, qt_TexCoord0);
103-
float alpha = 1.0;
104-
if(qt_TexCoord0.y < 0.2)
105-
alpha = qt_TexCoord0.y*5.0;
106-
if(qt_TexCoord0.y > 0.8)
107-
alpha = (1.0-qt_TexCoord0.y)*5.0;
108-
gl_FragColor = sourceColor * alpha;
109-
}"
96+
fragmentShader: "Spinner.frag.qsb"
11097
}
11198
}

src/controls/qml/Spinner.frag

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#version 440
2+
layout(location = 0) in vec2 qt_TexCoord0;
3+
layout(location = 0) out vec4 fragColor;
4+
layout(binding = 1) uniform sampler2D source;
5+
void main(void)
6+
{
7+
vec4 sourceColor = texture(source, qt_TexCoord0);
8+
float alpha = 1.0;
9+
if(qt_TexCoord0.y < 0.2)
10+
alpha = qt_TexCoord0.y*5.0;
11+
if(qt_TexCoord0.y > 0.8)
12+
alpha = (1.0-qt_TexCoord0.y)*5.0;
13+
fragColor = sourceColor * alpha;
14+
}

src/controls/qml/Spinner.qml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,6 @@ ListView {
7272

7373
layer.enabled: true
7474
layer.effect: ShaderEffect {
75-
fragmentShader: "
76-
precision mediump float;
77-
varying highp vec2 qt_TexCoord0;
78-
uniform sampler2D source;
79-
void main(void)
80-
{
81-
vec4 sourceColor = texture2D(source, qt_TexCoord0);
82-
float alpha = 1.0;
83-
if(qt_TexCoord0.y < 0.2)
84-
alpha = qt_TexCoord0.y*5.0;
85-
if(qt_TexCoord0.y > 0.8)
86-
alpha = (1.0-qt_TexCoord0.y)*5.0;
87-
gl_FragColor = sourceColor * alpha;
88-
}"
75+
fragmentShader: "Spinner.frag.qsb"
8976
}
9077
}

0 commit comments

Comments
 (0)