a6fcc260cdf292c47c3ad1e0a61f2e6d84c546a5
[profile/ivi/qtdeclarative.git] / tests / manual / scenegraph_lancelot / data / shaders / culling / culling_2.qml
1 import QtQuick 2.0
2
3 Rectangle {
4     id: topLevel
5     width: 320
6     height: 480
7     ShaderEffectSource {
8         id: front
9         visible: false
10         smooth: true
11         sourceItem: Rectangle {
12             width: 256
13             height: 64
14             color: "cornflowerblue"
15             radius: 8
16             Text {
17                 anchors.centerIn: parent
18                 text: "Front"
19                 font.pixelSize: 48
20                 color: "white"
21             }
22         }
23     }
24     ShaderEffectSource {
25         id: back
26         visible: false
27         smooth: true
28         sourceItem: Rectangle {
29             width: 256
30             height: 64
31             color: "firebrick"
32             radius: 8
33             Text {
34                 anchors.centerIn: parent
35                 text: "Back"
36                 font.pixelSize: 48
37                 color: "white"
38             }
39         }
40     }
41     Column {
42         anchors.fill: parent
43         Repeater {
44             model: ListModel {
45                 ListElement {
46                     foo: "No culling"
47                     bar: ShaderEffect.NoCulling
48                     turned: true
49                 }
50                 ListElement {
51                     foo: "Back-face culling"
52                     bar: ShaderEffect.BackFaceCulling
53                     turned: true
54                 }
55                 ListElement {
56                     foo: "Front-face culling"
57                     bar: ShaderEffect.FrontFaceCulling
58                     turned: true
59                 }
60             }
61
62             Item{
63                 id: item_0000
64                 width: 320
65                 height: 120
66                 ShaderEffect{
67                     anchors.right: parent.right
68                     anchors.verticalCenter: parent.verticalCenter
69                     anchors.margins: 10
70                     width: 200
71                     height: 100
72                     culling: model.bar
73                     property variant frontSource: front
74                     property variant backSource: back
75                     fragmentShader: "
76                             varying highp vec2 qt_TexCoord0;
77                             uniform sampler2D frontSource;
78                             uniform sampler2D backSource;
79                             uniform lowp float qt_Opacity;
80                             void main() {
81                                 gl_FragColor = gl_FrontFacing
82                                              ? texture2D(frontSource, qt_TexCoord0)
83                                              : texture2D(backSource, qt_TexCoord0);
84                             }"
85                     transform: Rotation {
86                         origin.x: 100
87                         origin.y: 180 - 120 * index
88                         axis { x: 0; y: 1; z: 0 }
89                         angle: (turned == true) ? 180 : 0
90
91                     }
92                 }
93                 Text {
94                     font.pointSize: 10
95                     anchors.verticalCenter: parent.verticalCenter
96                     anchors.left: parent.left
97                     anchors.margins: 5
98                     text: foo
99                 }
100             }
101         }
102     }
103 }