aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/scenegraph_lancelot/data/shaders/culling/culling_1.qml
blob: 47687918e0ef6f09f04e5c63450403f4cbd65fd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import QtQuick 2.0

Rectangle {
    id: topLevel
    width: 320
    height: 480
    ShaderEffectSource {
        id: front
        visible: false
        smooth: true
        sourceItem: Rectangle {
            width: 256
            height: 64
            color: "cornflowerblue"
            radius: 8
            Text {
                anchors.centerIn: parent
                text: "Front"
                font.pixelSize: 48
                color: "white"
            }
        }
    }
    ShaderEffectSource {
        id: back
        visible: false
        smooth: true
        sourceItem: Rectangle {
            width: 256
            height: 64
            color: "firebrick"
            radius: 8
            Text {
                anchors.centerIn: parent
                text: "Back"
                font.pixelSize: 48
                color: "white"
            }
        }
    }
    Column {
        anchors.fill: parent
        Repeater {
            model: ListModel {
                ListElement {
                    foo: "No culling"
                    bar: ShaderEffect.NoCulling
                    turned: false
                }
                ListElement {
                    foo: "Back-face culling"
                    bar: ShaderEffect.BackFaceCulling
                    turned: false
                }
                ListElement {
                    foo: "Front-face culling"
                    bar: ShaderEffect.FrontFaceCulling
                    turned: false
                }
            }

            Item{
                id: item_0000
                width: 320
                height: 120
                ShaderEffect {
                    anchors.right: parent.right
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.margins: 10
                    width: 200
                    height: 100
                    culling: model.bar
                    property variant frontSource: front
                    property variant backSource: back
                    fragmentShader: "
                            varying highp vec2 qt_TexCoord0;
                            uniform sampler2D frontSource;
                            uniform sampler2D backSource;
                            uniform lowp float qt_Opacity;
                            void main() {
                                gl_FragColor = gl_FrontFacing
                                             ? texture2D(frontSource, qt_TexCoord0)
                                             : texture2D(backSource, qt_TexCoord0);
                            }"
                    transform: Rotation {
                        origin.x: 200
                        origin.y: 180 - 120 * index
                        axis { x: 0; y: 1; z: 0 }
                        angle: (turned == true) ? 180 : 0

                    }
                }
                Text {
                    font.pointSize: 10
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.margins: 5
                    text: foo
                }
            }
        }
    }
}