]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/bunny/bunny.factor
interpolate: split out format into a hook
[factor.git] / extra / bunny / bunny.factor
old mode 100755 (executable)
new mode 100644 (file)
index 620f737..d6b77b1
@@ -1,7 +1,7 @@
 USING: accessors arrays bunny.cel-shaded bunny.fixed-pipeline
-bunny.model bunny.outlined destructors kernel math opengl.demo-support
-opengl.gl sequences ui ui.gadgets ui.gadgets.worlds ui.gestures
-ui.render words ui.pixel-formats ;
+bunny.model bunny.outlined destructors kernel literals math
+opengl.demo-support opengl.gl sequences ui ui.gadgets
+ui.gadgets.worlds ui.gestures ui.pixel-formats ;
 IN: bunny
 
 TUPLE: bunny-world < demo-world model-triangles geom draw-seq draw-n ;
@@ -11,7 +11,7 @@ TUPLE: bunny-world < demo-world model-triangles geom draw-seq draw-n ;
 
 : next-draw ( gadget -- )
     dup [ draw-seq>> ] [ draw-n>> ] bi
-    1+ swap length mod
+    1 + swap length mod
     >>draw-n relayout-1 ;
 
 : make-draws ( gadget -- draw-seq )
@@ -23,7 +23,7 @@ TUPLE: bunny-world < demo-world model-triangles geom draw-seq draw-n ;
 M: bunny-world begin-world
     GL_DEPTH_TEST glEnable
     0.0 0.0 0.375 set-demo-orientation
-    maybe-download read-model
+    download-bunny read-model
     [ >>model-triangles ] [ <bunny-geom> >>geom ] bi
     dup make-draws >>draw-seq
     0 >>draw-n
@@ -37,31 +37,24 @@ M: bunny-world end-world
 M: bunny-world draw-world*
     dup draw-seq>> empty? [ drop ] [
         0.15 0.15 0.15 1.0 glClearColor
-        GL_DEPTH_BUFFER_BIT GL_COLOR_BUFFER_BIT bitor glClear
+        flags{ GL_DEPTH_BUFFER_BIT GL_COLOR_BUFFER_BIT } glClear
         dup demo-world-set-matrix
         GL_MODELVIEW glMatrixMode
         0.02 -0.105 0.0 glTranslatef
         [ geom>> ] [ get-draw ] bi draw-bunny
     ] if ;
 
-M: bunny-world pref-dim* ( gadget -- dim )
-    drop { 640 480 } ;
-    
 bunny-world H{
     { T{ key-down f f "TAB" } [ next-draw ] }
 } set-gestures
 
-: bunny-window ( -- )
-    [
-        f T{ world-attributes
-            { world-class bunny-world }
-            { title "Bunny" }
-            { pixel-format-attributes {
-                windowed
-                double-buffered
-                T{ depth-bits { value 16 } }
-            } }
-        } open-window
-    ] with-ui ;
-
-MAIN: bunny-window
+MAIN-WINDOW: bunny-window {
+    { world-class bunny-world }
+    { title "Bunny" }
+    { pixel-format-attributes {
+        windowed
+        double-buffered
+        T{ depth-bits { value 16 } }
+    } }
+    { pref-dim { 640 480 } }
+} ;