1 USING: accessors arrays bunny.cel-shaded bunny.fixed-pipeline
2 bunny.model bunny.outlined destructors kernel math opengl.demo-support
3 opengl.gl sequences ui ui.gadgets ui.gadgets.worlds ui.gestures
7 TUPLE: bunny-gadget < demo-gadget model-triangles geom draw-seq draw-n ;
9 : <bunny-gadget> ( -- bunny-gadget )
10 0.0 0.0 0.375 bunny-gadget new-demo-gadget
11 maybe-download read-model >>model-triangles ;
13 : bunny-gadget-draw ( gadget -- draw )
14 [ draw-n>> ] [ draw-seq>> ] bi nth ;
16 : bunny-gadget-next-draw ( gadget -- )
17 dup [ draw-seq>> ] [ draw-n>> ] bi
21 M: bunny-gadget graft* ( gadget -- )
23 GL_DEPTH_TEST glEnable
24 dup model-triangles>> <bunny-geom> >>geom
26 [ <bunny-fixed-pipeline> ]
27 [ <bunny-cel-shaded> ]
28 [ <bunny-outlined> ] tri 3array
33 M: bunny-gadget ungraft* ( gadget -- )
35 [ geom>> [ dispose ] when* ]
36 [ draw-seq>> [ [ dispose ] when* ] each ] bi ;
38 M: bunny-gadget draw-gadget* ( gadget -- )
39 dup draw-seq>> empty? [ drop ] [
40 0.15 0.15 0.15 1.0 glClearColor
41 GL_DEPTH_BUFFER_BIT GL_COLOR_BUFFER_BIT bitor glClear
42 dup demo-gadget-set-matrices
43 GL_MODELVIEW glMatrixMode
44 0.02 -0.105 0.0 glTranslatef
45 [ geom>> ] [ bunny-gadget-draw ] bi draw-bunny
48 M: bunny-gadget pref-dim* ( gadget -- dim )
52 { T{ key-down f f "TAB" } [ bunny-gadget-next-draw ] }
56 [ <bunny-gadget> "Bunny" open-window ] with-ui ;