5 #######################################################################
6 # Extend OpenGl_Context to store map of shared GPU resources
7 #######################################################################
12 # This test is modified test cdl/934/C2
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
20 set BUGNUMBER OCC22583
22 set ImageName1 "occ22583-image1.png"
23 set ImageName2 "occ22583-image2.png"
25 # set window width and height, this values should correspond to a
26 # view window sizes to pass the test
30 # colors used for tests
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
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"
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
78 # move cursor not to select shape
82 # test pixels in a top left corner
85 for {set i 0} {$i < $limit_x} {incr i} {
86 for {set j 0} {$j < $limit_y} {incr j} {
87 if { "[vreadpixel $i $j rgb]" == "$r $g $b" } {
92 if { $HasPixel == 1 } {
93 set TestPassed [expr $TestPassed + 1]
98 # test pixels in bottom left corner
100 for {set i 0} {$i < $limit_x} {incr i} {
101 for {set j 0} {$j < $limit_y} {incr j} {
102 set coord_y [expr $view_height-$j]
103 if { "[vreadpixel $i $coord_y rgb]" == "$r $g $b" } {
108 if { $HasPixel == 1 } {
109 set TestPassed [expr $TestPassed + 1]
114 # test pixels in center right corner
116 for {set i 0} {$i < $limit_x} {incr i} {
117 for {set j 0} {$j < $limit_y} {incr j} {
118 set coord_x [expr ($view_width-$limit_y) + $i]
119 set coord_y [expr ($view_height-$limit_y)/2 + $j]
120 if { "[vreadpixel $coord_x $coord_y rgb]" == "$r $g $b" } {
125 if { $HasPixel == 1 } {
126 set TestPassed [expr $TestPassed + 1]
131 # test pixels in center left corner (shouldn't be anything)
133 for {set i 0} {$i < $limit_x} {incr i} {
134 for {set j 0} {$j < $limit_y} {incr j} {
135 set coord_x [expr $view_width/4 + $i]
136 set coord_y [expr ($view_height-$limit_y)/2 + $j]
137 if { "[vreadpixel $coord_x $coord_y rgb]" == "$r $g $b" } {
142 if { $HasPixel == 1 } {
145 set TestPassed [expr $TestPassed + 1]
148 # show all primitives
154 if { ${TestPassed} == 4 } {
161 # ### THIS IS THE HEAD LOOP OF THE TEST ####################
162 # During this test primitives are created and displayed
163 # with commands vdrawparray, and verified for consistency
164 # with check_primitive procedure. In spite of the fact that there
165 # a lot of code below, it's similar and divided on the similar
167 # The iteration loop is intended to check primitives with
168 # "vertex buffer objects" turned off (vbo_enable = 0) and
169 # turned on (vbo_enable = 1)
171 for {set vbo_enable 0} {$vbo_enable < 2} {incr vbo_enable} {
173 if { $vbo_enable == 0 } {
175 puts "TEST WITH VBO is OFF"
177 if { $vbo_enable == 1 } {
179 puts "TEST WITH VBO is ON"
186 # this points are only to simplify visiual check of dumped image
188 vpoint point2 -145 0 0
190 # ****************************** Graphic3d_ArrayOfPoints ****************************** #
191 puts "Graphic3d_ArrayOfPoints: TEST"
195 generate_points 60 0 0 $colorY_R $colorY_G $colorY_B
196 eval vdrawparray pt01 points $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06
198 # ****************************** Graphic3d_ArrayOfSegments ****************************** #
199 puts "Graphic3d_ArrayOfSegments: TEST"
203 generate_points 50 0 0 $colorY_R $colorY_G $colorY_B
204 eval vdrawparray seg01 segments $vbo_enable $pts02 $pts01 $pts01 $pts03 $pts03 $pts05 $pts05 $pts06 $pts06 $pts04 $pts04 $pts02
208 generate_points 40 0 0 $colorR_R $colorR_G $colorR_B
209 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
211 # ****************************** Graphic3d_ArrayOfPolylines ****************************** #
212 puts "Graphic3d_ArrayOfPolylines: TEST"
216 generate_points 30 0 0 $colorY_R $colorY_G $colorY_B
217 eval vdrawparray pline01 polylines $vbo_enable $pts02 $pts01 $pts03 $pts05 $pts06 $pts04 $pts02
221 generate_points 20 0 0 $colorR_R $colorR_G $colorR_B
222 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
226 generate_points 10 0 0 $colorY_R $colorY_G $colorY_B
227 eval vdrawparray pline03 polylines $vbo_enable ( b 3 ( $pts02 $pts01 $pts03 )), ( b 4 ( $pts03 $pts05 $pts06 $pts04 )), ( b 2 ( $pts04 $pts02 ))
229 # 4: verticies, bounds and edges
231 generate_points 0 0 0 $colorR_R $colorR_G $colorR_B
232 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 ))
234 # ****************************** Graphic3d_ArrayOfTriangles ****************************** #
235 puts "Graphic3d_ArrayOfTriangles: TEST"
239 generate_points -10 0 0 $colorB_R $colorB_G $colorB_B
240 eval vdrawparray t01 triangles $vbo_enable ( $pts03 $pts02 $pts01 ) , ( $pts03 $pts04 $pts02 ) , ( $pts04 $pts03 $pts06 ) , ( $pts06 $pts03 $pts05 )
244 generate_points -20 0 0 $colorG_R $colorG_G $colorG_B
245 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
247 # ****************************** Graphic3d_ArrayOfTriangleFans ****************************** #
248 puts "Graphic3d_ArrayOfTriangleFans: TEST"
252 generate_points -30 0 0 $colorB_R $colorB_G $colorB_B
253 eval vdrawparray tfan01 trianglefans $vbo_enable ( $pts02 $pts01 $pts03 $pts04 )
254 eval vdrawparray tfan02 trianglefans $vbo_enable ( $pts03 $pts05 $pts06 $pts04 )
256 # 2: bounds and verticies
258 generate_points -40 0 0 $colorG_R $colorG_G $colorG_B
259 eval vdrawparray tfan03 trianglefans $vbo_enable ( b 4 ( $pts02 $pts01 $pts03 $pts04 )), ( b 4 ( $pts03 $pts05 $pts06 $pts04 ))
261 # ****************************** Graphic3d_ArrayOfTriangleStrips ****************************** #
262 puts "Graphic3d_ArrayOfTriangleStrips: TEST"
266 generate_points -50 0 0 $colorB_R $colorB_G $colorB_B
267 eval vdrawparray tstrip01 trianglestrips $vbo_enable ( $pts06 $pts04 $pts03 $pts02 $pts01 )
268 eval vdrawparray tstrip02 trianglestrips $vbo_enable ( $pts03 $pts05 $pts06 )
270 # 2: bounds and verticies
272 generate_points -60 0 0 $colorG_R $colorG_G $colorG_B
273 eval vdrawparray tstrip03 trianglestrips $vbo_enable ( b 5 ( $pts06 $pts04 $pts03 $pts02 $pts01 )) , ( b 3 ( $pts03 $pts05 $pts06 ))
275 # ****************************** Graphic3d_ArrayOfQuadrangles ****************************** #
276 puts "Graphic3d_ArrayOfQuadrangles: TEST"
280 generate_points -70 0 0 $colorB_R $colorB_G $colorB_B
281 eval vdrawparray q01 quads $vbo_enable ( $pts01 $pts03 $pts04 $pts02 )
282 eval vdrawparray q02 quads $vbo_enable ( $pts03 $pts05 $pts06 $pts04 )
284 # 2: verticies and edges
286 generate_points -80 0 0 $colorG_R $colorG_G $colorG_B
287 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
289 # ****************************** Graphic3d_ArrayOfQuadrangleStrips ****************************** #
290 puts "Graphic3d_ArrayOfQuadrangleStrips: TEST"
294 generate_points -90 0 0 $colorB_R $colorB_G $colorB_B
295 eval vdrawparray qstrips01 quadstrips $vbo_enable ( $pts02 $pts01 $pts04 $pts03 $pts06 $pts05 )
297 # 2: verticies and edges
299 generate_points -100 0 0 $colorG_R $colorG_G $colorG_B
300 eval vdrawparray qstrips02 quadstrips $vbo_enable ( b 4 ( $pts02 $pts01 $pts04 $pts03 )) , ( b 4 ( $pts04 $pts03 $pts06 $pts05 ))
302 # ****************************** Graphic3d_ArrayOfPolygons ****************************** #
303 puts "Graphic3d_ArrayOfPolygons: TEST"
307 generate_points -110 0 0 $colorB_R $colorB_G $colorB_B
308 eval vdrawparray poly01 polygons $vbo_enable ( $pts04 $pts02 $pts01 $pts03 $pts05 $pts06 )
310 # 2: verticies and bounds
312 generate_points -120 0 0 $colorG_R $colorG_G $colorG_B
313 eval vdrawparray poly02 polygons $vbo_enable ( b 5 ( $pts04 $pts02 $pts01 $pts03 $pts06 )) , ( b 3 ( $pts06 $pts03 $pts05 ))
315 # 3: verticies and edges
317 generate_points -130 0 0 $colorB_R $colorB_G $colorB_B
318 eval vdrawparray poly03 polygons $vbo_enable $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 e 4 e 2 e 1 e 3 e 5 e 6
320 # 4: vertices, bounds and edges
322 generate_points -140 0 0 $colorG_R $colorG_G $colorG_B
323 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 ))
328 # dump resulted image
329 if { $vbo_enable == 0 } { vfeedback; vdump ${imagedir}/$ImageName1 }
330 if { $vbo_enable == 1 } { vfeedback; vdump ${imagedir}/$ImageName2 }
334 # delete internal procedures
335 rename generate_points ""
336 rename check_primitive ""
338 checkcolor 200 200 $colorG_R $colorG_G $colorG_B
339 checkcolor 220 200 $colorB_R $colorB_G $colorB_B
341 puts "BUG OK ${BUGNUMBER}"
343 puts "BUG FAULTY ${BUGNUMBER}"