Skip to content

Commit 79d9259

Browse files
committed
Port {Circular,}Spinner fragmentShader to Qt6 (qsb)
1 parent c687fb8 commit 79d9259

File tree

4 files changed

+23
-28
lines changed

4 files changed

+23
-28
lines changed

src/controls/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ qt_add_resources(asteroidcontrolsplugin "asteroidcontrolsplugin_qrc"
4848
PREFIX "/org/asteroid/controls/"
4949
FILES "${controls-qml}")
5050

51+
qt6_add_shaders(asteroidcontrolsplugin "asteroidcontrolsplugin_shaders"
52+
PREFIX "/org/asteroid/controls/"
53+
FILES "qml/Spinner.frag"
54+
BATCHABLE
55+
PRECOMPILE
56+
OPTIMIZED)
57+
5158
set(controls-docs "$<LIST:TRANSFORM,$<LIST:TRANSFORM,$<LOWER_CASE:${controls}>,PREPEND,qml->,APPEND,.html>")
5259
set(doc-dir "${CMAKE_BINARY_DIR}/doc/html")
5360
set(full-controls-docs "$<LIST:TRANSFORM,${controls-docs},PREPEND,${doc-dir}>")

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)