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 } {
163 # ### THIS IS THE HEAD LOOP OF THE TEST ####################
164 # During this test primitives are created and displayed
165 # with commands vdrawparray, and verified for consistency
166 # with check_primitive procedure. In spite of the fact that there
167 # a lot of code below, it's similar and divided on the similar
169 # The iteration loop is intended to check primitives with
170 # "vertex buffer objects" turned off (vbo_enable = 0) and
171 # turned on (vbo_enable = 1)
172 for {set vbo_enable 0} {$vbo_enable < 2} {incr vbo_enable} {
173 for {set isNonInterleaved 0} {$isNonInterleaved < 2} {incr isNonInterleaved} {
178 if { $vbo_enable == 0 } {
179 puts "TEST WITH VBO is OFF"
181 puts "TEST WITH VBO is ON"
184 if { $isNonInterleaved == 1 } { set aParams "-deinterleaved" }
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"
192 generate_points 60 0 0 $colorY_R $colorY_G $colorY_B
193 eval vdrawparray pt01 points {*}$aParams $pts01 $pts02 $pts03 $pts04 $pts05 $pts06
195 # ****************************** Graphic3d_ArrayOfSegments ****************************** #
196 puts "Graphic3d_ArrayOfSegments: TEST"
199 generate_points 50 0 0 $colorY_R $colorY_G $colorY_B
200 eval vdrawparray seg01 segments {*}$aParams $pts02 $pts01 $pts01 $pts03 $pts03 $pts05 $pts05 $pts06 $pts06 $pts04 $pts04 $pts02
203 generate_points 40 0 0 $colorR_R $colorR_G $colorR_B
204 eval vdrawparray seg02 segments {*}$aParams $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
206 # ****************************** Graphic3d_ArrayOfPolylines ****************************** #
207 puts "Graphic3d_ArrayOfPolylines: TEST"
210 generate_points 30 0 0 $colorY_R $colorY_G $colorY_B
211 eval vdrawparray pline01 polylines {*}$aParams $pts02 $pts01 $pts03 $pts05 $pts06 $pts04 $pts02
214 generate_points 20 0 0 $colorR_R $colorR_G $colorR_B
215 eval vdrawparray pline02 polylines {*}$aParams $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 e 2 e 4 e 6 e 5 e 3 e 1 e 2
218 generate_points 10 0 0 $colorY_R $colorY_G $colorY_B
219 eval vdrawparray pline03 polylines {*}$aParams ( b 3 ( $pts02 $pts01 $pts03 )), ( b 4 ( $pts03 $pts05 $pts06 $pts04 )), ( b 2 ( $pts04 $pts02 ))
221 # 4: bounds and indexes
222 generate_points 0 0 0 $colorR_R $colorR_G $colorR_B
223 eval vdrawparray pline04 polylines {*}$aParams $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 ))
225 # ****************************** Graphic3d_ArrayOfTriangles ****************************** #
226 puts "Graphic3d_ArrayOfTriangles: TEST"
229 generate_points -10 0 0 $colorB_R $colorB_G $colorB_B
230 eval vdrawparray t01 triangles {*}$aParams ( $pts03 $pts02 $pts01 ) , ( $pts03 $pts04 $pts02 ) , ( $pts04 $pts03 $pts06 ) , ( $pts06 $pts03 $pts05 )
233 generate_points -20 0 0 $colorG_R $colorG_G $colorG_B
234 eval vdrawparray t02 triangles {*}$aParams $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
236 # ****************************** Graphic3d_ArrayOfTriangleFans ****************************** #
237 puts "Graphic3d_ArrayOfTriangleFans: TEST"
240 generate_points -30 0 0 $colorB_R $colorB_G $colorB_B
241 eval vdrawparray tfan01 trianglefans {*}$aParams ( $pts02 $pts01 $pts03 $pts04 )
242 eval vdrawparray tfan02 trianglefans {*}$aParams ( $pts03 $pts05 $pts06 $pts04 )
245 generate_points -40 0 0 $colorG_R $colorG_G $colorG_B
246 eval vdrawparray tfan03 trianglefans {*}$aParams ( b 4 ( $pts02 $pts01 $pts03 $pts04 )), ( b 4 ( $pts03 $pts05 $pts06 $pts04 ))
248 # ****************************** Graphic3d_ArrayOfTriangleStrips ****************************** #
249 puts "Graphic3d_ArrayOfTriangleStrips: TEST"
252 generate_points -50 0 0 $colorB_R $colorB_G $colorB_B
253 eval vdrawparray tstrip01 trianglestrips {*}$aParams ( $pts06 $pts04 $pts03 $pts02 $pts01 )
254 eval vdrawparray tstrip02 trianglestrips {*}$aParams ( $pts03 $pts05 $pts06 )
257 generate_points -60 0 0 $colorG_R $colorG_G $colorG_B
258 eval vdrawparray tstrip03 trianglestrips {*}$aParams ( b 5 ( $pts06 $pts04 $pts03 $pts02 $pts01 )) , ( b 3 ( $pts03 $pts05 $pts06 ))
260 # ****************************** Graphic3d_ArrayOfQuadrangles ****************************** #
261 puts "Graphic3d_ArrayOfQuadrangles: TEST"
264 generate_points -70 0 0 $colorB_R $colorB_G $colorB_B
265 eval vdrawparray q01 quads {*}$aParams ( $pts01 $pts03 $pts04 $pts02 )
266 eval vdrawparray q02 quads {*}$aParams ( $pts03 $pts05 $pts06 $pts04 )
269 generate_points -80 0 0 $colorG_R $colorG_G $colorG_B
270 eval vdrawparray q03 quads {*}$aParams $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 e 1 e 3 e 4 e 2 e 3 e 5 e 6 e 4
272 # ****************************** Graphic3d_ArrayOfQuadrangleStrips ****************************** #
273 puts "Graphic3d_ArrayOfQuadrangleStrips: TEST"
276 generate_points -90 0 0 $colorB_R $colorB_G $colorB_B
277 eval vdrawparray qstrips01 quadstrips {*}$aParams ( $pts02 $pts01 $pts04 $pts03 $pts06 $pts05 )
280 generate_points -100 0 0 $colorG_R $colorG_G $colorG_B
281 eval vdrawparray qstrips02 quadstrips {*}$aParams ( b 4 ( $pts02 $pts01 $pts04 $pts03 )) , ( b 4 ( $pts04 $pts03 $pts06 $pts05 ))
283 # ****************************** Graphic3d_ArrayOfPolygons ****************************** #
284 puts "Graphic3d_ArrayOfPolygons: TEST"
287 generate_points -110 0 0 $colorB_R $colorB_G $colorB_B
288 eval vdrawparray poly01 polygons {*}$aParams ( $pts04 $pts02 $pts01 $pts03 $pts05 $pts06 )
291 generate_points -120 0 0 $colorG_R $colorG_G $colorG_B
292 eval vdrawparray poly02 polygons {*}$aParams ( b 5 ( $pts04 $pts02 $pts01 $pts03 $pts06 )) , ( b 3 ( $pts06 $pts03 $pts05 ))
295 generate_points -130 0 0 $colorB_R $colorB_G $colorB_B
296 eval vdrawparray poly03 polygons {*}$aParams $pts01 $pts02 $pts03 $pts04 $pts05 $pts06 e 4 e 2 e 1 e 3 e 5 e 6
298 # 4: bounds and indexes
299 generate_points -140 0 0 $colorG_R $colorG_G $colorG_B
300 eval vdrawparray poly04 polygons {*}$aParams $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 ))
302 # dump resulted image
303 set anImgName "${casename}"
304 if { $vbo_enable == 0 } { set anImgName "${anImgName}_vbooff" }
305 if { $vbo_enable == 1 } { set anImgName "${anImgName}_vboon" }
306 if { $isNonInterleaved == 1 } { set anImgName "${anImgName}_noninter" }
308 vdump ${imagedir}/${anImgName}.png
312 # delete internal procedures
313 rename generate_points ""
314 rename check_primitive ""
316 checkcolor 200 200 $colorG_R $colorG_G $colorG_B
317 checkcolor 220 200 $colorB_R $colorB_G $colorB_B
319 puts "BUG OK ${BUGNUMBER}"
321 puts "BUG FAULTY ${BUGNUMBER}"