3bea4c16 |
1 | puts "============" |
2 | puts "OCC23226" |
3 | puts "============" |
4 | puts "" |
5 | ####################################################################### |
6 | # Extend OpenGl_Context to store map of shared GPU resources |
7 | ####################################################################### |
8 | |
9 | set BugNumber OCC23226 |
10 | |
11 | # |
12 | # This test is modified test cdl/934/C2 |
13 | # |
14 | |
15 | # this test performs automatical test of primitives array objects by pixel checking |
16 | # this test ALSO DUMPS two result images (the primitives on the images should have |
17 | # same contours, WIREFRAME OBJECTS ARE IN YELLOW-RED COLORS, SHADED OBJECTS ARE |
18 | # BLUE-GREEN COLORS) |
19 | |
20 | set BUGNUMBER OCC22583 |
21 | set status 0 |
22 | set ImageName1 "occ22583-image1.png" |
23 | set ImageName2 "occ22583-image2.png" |
24 | |
25 | # set window width and height, this values should correspond to a |
26 | # view window sizes to pass the test |
27 | set view_width 405 |
28 | set view_height 405 |
29 | |
30 | # colors used for tests |
31 | # yellow |
32 | set colorY_R 1 |
33 | set colorY_G 1 |
34 | set colorY_B 0 |
35 | |
36 | # red |
37 | set colorR_R 1 |
38 | set colorR_G 0 |
39 | set colorR_B 0 |
40 | |
41 | # blue |
42 | set colorB_R 0 |
43 | set colorB_G 1 |
44 | set colorB_B 1 |
45 | |
46 | # green |
47 | set colorG_R 0 |
48 | set colorG_G 1 |
49 | set colorG_B 0 |
50 | |
51 | # limit of range where the pixels are tested (sets number of iterations) |
52 | # 30 pixels in width and in height will be enough to test all primitives |
53 | set limit_x 3 |
54 | set limit_y 3 |
55 | |
56 | # this procedure is internal and will be removed at the end of the script |
57 | # generate points for primitive |
58 | proc generate_points {x y z r g b} { |
59 | # define top plane points |
60 | global pts01 pts02 pts03 pts04 pts05 pts06 |
61 | set pts01 "v [expr "$x-5"] [expr "$y+5"] [expr "$z"] n 0 0 -1 c $r $g $b" |
62 | set pts02 "v [expr "$x "] [expr "$y+5"] [expr "$z"] n 0 0 -1 c $r $g $b" |
63 | set pts03 "v [expr "$x "] [expr "$y "] [expr "$z"] n 0 0 -1 c $r $g $b" |
64 | set pts04 "v [expr "$x+5"] [expr "$y "] [expr "$z"] n 0 0 -1 c $r $g $b" |
65 | set pts05 "v [expr "$x-5"] [expr "$y-5"] [expr "$z"] n 0 0 -1 c $r $g $b" |
66 | set pts06 "v [expr "$x "] [expr "$y-5"] [expr "$z"] n 0 0 -1 c $r $g $b" |
67 | } |
68 | |
69 | # this procedure is internal and will be removed at the end of the script |
70 | # check pixels of primitive |
71 | proc check_primitive {name1 r g b args} { |
72 | global limit_x limit_y view_width view_height |
73 | # show only primitive that we interested in to test |
74 | vdonly $name1 $args |
75 | vtop |
76 | vfit |
77 | |
78 | # move cursor not to select shape |
79 | vmoveto 0 0 |
80 | vmoveto 0 0 |
81 | |
82 | # test pixels in a top left corner |
83 | set TestPassed 0 |
84 | set HasPixel 0 |
85 | for {set i 0} {$i < $limit_x} {incr i} { |
86 | for {set j 0} {$j < $limit_y} {incr j} { |
87 | set QATestVar [ catch { QAGetPixelColor $i $j $r $g $b } ] |
88 | if { $QATestVar == 0 } { |
89 | set HasPixel 1 |
90 | } |
91 | } |
92 | } |
93 | if { $HasPixel == 1 } { |
94 | set TestPassed [expr $TestPassed + 1] |
95 | } else { |
96 | set TestPassed 0 |
97 | } |
98 | |
99 | # test pixels in bottom left corner |
100 | set HasPixel 1 |
101 | for {set i 0} {$i < $limit_x} {incr i} { |
102 | for {set j 0} {$j < $limit_y} {incr j} { |
103 | set QATestVar [ catch { QAGetPixelColor $i [expr $view_height-$j] $r $g $b } ] |
104 | if { $QATestVar == 0 } { |
105 | set HasPixel 1 |
106 | } |
107 | } |
108 | } |
109 | if { $HasPixel == 1 } { |
110 | set TestPassed [expr $TestPassed + 1] |
111 | } else { |
112 | set TestPassed 0 |
113 | } |
114 | |
115 | # test pixels in center right corner |
116 | set HasPixel 1 |
117 | for {set i 0} {$i < $limit_x} {incr i} { |
118 | for {set j 0} {$j < $limit_y} {incr j} { |
119 | set QATestVar [ catch { QAGetPixelColor [expr ($view_width-$limit_y) + $i] [expr ($view_height-$limit_y)/2 + $j] $r $g $b } ] |
120 | if { $QATestVar == 0 } { |
121 | set HasPixel 1 |
122 | } |
123 | } |
124 | } |
125 | if { $HasPixel == 1 } { |
126 | set TestPassed [expr $TestPassed + 1] |
127 | } else { |
128 | set TestPassed 0 |
129 | } |
130 | |
131 | # test pixels in center left corner (shouldn't be anything) |
132 | set HasPixel 0 |
133 | for {set i 0} {$i < $limit_x} {incr i} { |
134 | for {set j 0} {$j < $limit_y} {incr j} { |
135 | set QATestVar [ catch { QAGetPixelColor [expr $view_width/4 + $i] [expr ($view_height-$limit_y)/2 + $j] $r $g $b } ] |
136 | if { $QATestVar == 0 } { |
137 | set HasPixel 1 |
138 | } |
139 | } |
140 | } |
141 | if { $HasPixel == 1 } { |
142 | set TestPassed 0 |
143 | } else { |
144 | set TestPassed [expr $TestPassed + 1] |
145 | } |
146 | |
147 | # show all primitives |
148 | vdisplayall |
149 | vtop |
150 | vfit |
151 | |
152 | # return a result |
153 | if { ${TestPassed} == 4 } { |
154 | return 1 |
155 | } else { |
156 | return 0 |
157 | } |
158 | } |
159 | |
160 | # ### THIS IS THE HEAD LOOP OF THE TEST #################### |
161 | # During this test primitives are created and displayed |
162 | # with commands vdrawparray, and verified for consistency |
163 | # with check_primitive procedure. In spite of the fact that there |
164 | # a lot of code below, it's similar and divided on the similar |
165 | # blocks of code. |
166 | # The iteration loop is intended to check primitives with |
167 | # "vertex buffer objects" turned off (vbo_enable = 0) and |
168 | # turned on (vbo_enable = 1) |
169 | |
170 | for {set vbo_enable 0} {$vbo_enable < 2} {incr vbo_enable} { |
5d1833ef |
171 | vinit |
3bea4c16 |
172 | if { $vbo_enable == 0 } { |
173 | vvbo 0 |
174 | puts "TEST WITH VBO is OFF" |
175 | } |
176 | if { $vbo_enable == 1 } { |
177 | vvbo 1 |
178 | puts "TEST WITH VBO is ON" |
179 | } |
180 | |
5d1833ef |
181 | ## vinit |
3bea4c16 |
182 | veraseall |
183 | vclear |
184 | |
185 | # this points are only to simplify visiual check of dumped image |
186 | vpoint point1 65 0 0 |
187 | vpoint point2 -145 0 0 |
188 | |
189 | # ****************************** Graphic3d_ArrayOfPoints ****************************** # |
3bea4c16 |
190 | puts "Graphic3d_ArrayOfPoints: TEST" |
191 | # |
192 | # 1: verticies |
193 | # |
194 | generate_points 60 0 0 $colorY_R $colorY_G $colorY_B |
195 | eval vdrawparray pt01 points $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 |
3bea4c16 |
196 | |
197 | # ****************************** Graphic3d_ArrayOfSegments ****************************** # |
3bea4c16 |
198 | puts "Graphic3d_ArrayOfSegments: TEST" |
199 | # |
200 | # 1: verticies |
201 | # |
202 | generate_points 50 0 0 $colorY_R $colorY_G $colorY_B |
203 | eval vdrawparray seg01 segments $vbo_enable $pts02 $pts01 $pts01 $pts03 $pts03 $pts05 $pts05 $pts06 $pts06 $pts04 $pts04 $pts02 |
3bea4c16 |
204 | # |
205 | # 2: edges |
206 | # |
207 | generate_points 40 0 0 $colorR_R $colorR_G $colorR_B |
208 | eval vdrawparray seg02 segments $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 e 1 e 2 e 2 e 4 e 4 e 6 e 6 e 5 e 5 e 3 e 3 e 1 |
3bea4c16 |
209 | |
210 | # ****************************** Graphic3d_ArrayOfPolylines ****************************** # |
3bea4c16 |
211 | puts "Graphic3d_ArrayOfPolylines: TEST" |
212 | # |
213 | # 1: verticies |
214 | # |
215 | generate_points 30 0 0 $colorY_R $colorY_G $colorY_B |
216 | eval vdrawparray pline01 polylines $vbo_enable $pts02 $pts01 $pts03 $pts05 $pts06 $pts04 $pts02 |
3bea4c16 |
217 | # |
218 | # 2: edges |
219 | # |
220 | generate_points 20 0 0 $colorR_R $colorR_G $colorR_B |
221 | eval vdrawparray pline02 polylines $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 e 2 e 4 e 6 e 5 e 3 e 1 e 2 |
3bea4c16 |
222 | # |
223 | # 3: bounds |
224 | # |
225 | generate_points 10 0 0 $colorY_R $colorY_G $colorY_B |
226 | eval vdrawparray pline03 polylines $vbo_enable ( b 3 ( $pts02 $pts01 $pts03 )), ( b 4 ( $pts03 $pts05 $pts06 $pts04 )), ( b 2 ( $pts04 $pts02 )) |
3bea4c16 |
227 | # |
228 | # 4: verticies, bounds and edges |
229 | # |
230 | generate_points 0 0 0 $colorR_R $colorR_G $colorR_B |
231 | eval vdrawparray pline04 polylines $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 ( b 4 ( e 2 e 1 e 3 e 5 )), ( b 4 ( e 5 e 6 e 4 e 2 )) |
3bea4c16 |
232 | |
233 | # ****************************** Graphic3d_ArrayOfTriangles ****************************** # |
3bea4c16 |
234 | puts "Graphic3d_ArrayOfTriangles: TEST" |
235 | # |
236 | # 1: verticies |
237 | # |
238 | generate_points -10 0 0 $colorB_R $colorB_G $colorB_B |
239 | eval vdrawparray t01 triangles $vbo_enable ( $pts03 $pts02 $pts01 ) , ( $pts03 $pts04 $pts02 ) , ( $pts04 $pts03 $pts06 ) , ( $pts06 $pts03 $pts05 ) |
3bea4c16 |
240 | # |
241 | # 2: by edges |
242 | # |
243 | generate_points -20 0 0 $colorG_R $colorG_G $colorG_B |
244 | eval vdrawparray t02 triangles $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 e 6 e 3 e 5 e 6 e 4 e 3 e 1 e 3 e 2 e 2 e 3 e 4 |
3bea4c16 |
245 | |
246 | # ****************************** Graphic3d_ArrayOfTriangleFans ****************************** # |
3bea4c16 |
247 | puts "Graphic3d_ArrayOfTriangleFans: TEST" |
248 | # |
249 | # 1: verticies |
250 | # |
251 | generate_points -30 0 0 $colorB_R $colorB_G $colorB_B |
252 | eval vdrawparray tfan01 trianglefans $vbo_enable ( $pts02 $pts01 $pts03 $pts04 ) |
253 | eval vdrawparray tfan02 trianglefans $vbo_enable ( $pts03 $pts05 $pts06 $pts04 ) |
3bea4c16 |
254 | # |
255 | # 2: bounds and verticies |
256 | # |
257 | generate_points -40 0 0 $colorG_R $colorG_G $colorG_B |
258 | eval vdrawparray tfan03 trianglefans $vbo_enable ( b 4 ( $pts02 $pts01 $pts03 $pts04 )), ( b 4 ( $pts03 $pts05 $pts06 $pts04 )) |
3bea4c16 |
259 | |
260 | # ****************************** Graphic3d_ArrayOfTriangleStrips ****************************** # |
3bea4c16 |
261 | puts "Graphic3d_ArrayOfTriangleStrips: TEST" |
262 | # |
263 | # 1: verticies |
264 | # |
265 | generate_points -50 0 0 $colorB_R $colorB_G $colorB_B |
266 | eval vdrawparray tstrip01 trianglestrips $vbo_enable ( $pts06 $pts04 $pts03 $pts02 $pts01 ) |
267 | eval vdrawparray tstrip02 trianglestrips $vbo_enable ( $pts03 $pts05 $pts06 ) |
3bea4c16 |
268 | # |
269 | # 2: bounds and verticies |
270 | # |
271 | generate_points -60 0 0 $colorG_R $colorG_G $colorG_B |
272 | eval vdrawparray tstrip03 trianglestrips $vbo_enable ( b 5 ( $pts06 $pts04 $pts03 $pts02 $pts01 )) , ( b 3 ( $pts03 $pts05 $pts06 )) |
3bea4c16 |
273 | |
274 | # ****************************** Graphic3d_ArrayOfQuadrangles ****************************** # |
3bea4c16 |
275 | puts "Graphic3d_ArrayOfQuadrangles: TEST" |
276 | # |
277 | # 1: verticies |
278 | # |
279 | generate_points -70 0 0 $colorB_R $colorB_G $colorB_B |
280 | eval vdrawparray q01 quads $vbo_enable ( $pts01 $pts03 $pts04 $pts02 ) |
281 | eval vdrawparray q02 quads $vbo_enable ( $pts03 $pts05 $pts06 $pts04 ) |
3bea4c16 |
282 | # |
283 | # 2: verticies and edges |
284 | # |
285 | generate_points -80 0 0 $colorG_R $colorG_G $colorG_B |
286 | eval vdrawparray q03 quads $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 e 1 e 3 e 4 e 2 e 3 e 5 e 6 e 4 |
3bea4c16 |
287 | |
288 | # ****************************** Graphic3d_ArrayOfQuadrangleStrips ****************************** # |
3bea4c16 |
289 | puts "Graphic3d_ArrayOfQuadrangleStrips: TEST" |
290 | # |
291 | # 1: verticies |
292 | # |
293 | generate_points -90 0 0 $colorB_R $colorB_G $colorB_B |
294 | eval vdrawparray qstrips01 quadstrips $vbo_enable ( $pts02 $pts01 $pts04 $pts03 $pts06 $pts05 ) |
3bea4c16 |
295 | # |
296 | # 2: verticies and edges |
297 | # |
298 | generate_points -100 0 0 $colorG_R $colorG_G $colorG_B |
299 | eval vdrawparray qstrips02 quadstrips $vbo_enable ( b 4 ( $pts02 $pts01 $pts04 $pts03 )) , ( b 4 ( $pts04 $pts03 $pts06 $pts05 )) |
3bea4c16 |
300 | |
301 | # ****************************** Graphic3d_ArrayOfPolygons ****************************** # |
3bea4c16 |
302 | puts "Graphic3d_ArrayOfPolygons: TEST" |
303 | # |
304 | # 1: verticies |
305 | # |
306 | generate_points -110 0 0 $colorB_R $colorB_G $colorB_B |
307 | eval vdrawparray poly01 polygons $vbo_enable ( $pts04 $pts02 $pts01 $pts03 $pts05 $pts06 ) |
3bea4c16 |
308 | # |
309 | # 2: verticies and bounds |
310 | # |
311 | generate_points -120 0 0 $colorG_R $colorG_G $colorG_B |
312 | eval vdrawparray poly02 polygons $vbo_enable ( b 5 ( $pts04 $pts02 $pts01 $pts03 $pts06 )) , ( b 3 ( $pts06 $pts03 $pts05 )) |
3bea4c16 |
313 | # |
314 | # 3: verticies and edges |
315 | # |
316 | generate_points -130 0 0 $colorB_R $colorB_G $colorB_B |
317 | eval vdrawparray poly03 polygons $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 e 4 e 2 e 1 e 3 e 5 e 6 |
3bea4c16 |
318 | # |
319 | # 4: vertices, bounds and edges |
320 | # |
321 | generate_points -140 0 0 $colorG_R $colorG_G $colorG_B |
322 | eval vdrawparray poly04 polygons $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 ( b 5 ( e 4 e 2 e 1 e 3 e 6 )), ( b 3 ( e 6 e 3 e 5 )) |
3bea4c16 |
323 | |
324 | vtop |
325 | vfit |
326 | |
327 | # dump resulted image |
5879dab4 |
328 | if { $vbo_enable == 0 } { vfeedback; vdump ${imagedir}/$ImageName1 } |
329 | if { $vbo_enable == 1 } { vfeedback; vdump ${imagedir}/$ImageName2 } |
3bea4c16 |
330 | |
331 | } |
332 | |
333 | # delete internal procedures |
334 | rename generate_points "" |
335 | rename check_primitive "" |
336 | |
5d1833ef |
337 | checkcolor 200 200 $colorG_R $colorG_G $colorG_B |
338 | checkcolor 220 200 $colorB_R $colorB_G $colorB_B |
339 | if { $stat == 1 } { |
340 | puts "BUG OK ${BUGNUMBER}" |
3bea4c16 |
341 | } else { |
5d1833ef |
342 | puts "BUG FAULTY ${BUGNUMBER}" |
3bea4c16 |
343 | } |
344 | |
345 | set only_screen 1 |
346 | |
5d1833ef |
347 | |