]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/opengl/demo-support/demo-support.factor
factor: trim using lists
[factor.git] / extra / opengl / demo-support / demo-support.factor
old mode 100755 (executable)
new mode 100644 (file)
index e627a74..5c639e5
@@ -1,9 +1,9 @@
-USING: arrays kernel math math.functions math.order math.vectors
-namespaces opengl opengl.gl sequences ui ui.gadgets ui.gestures
-ui.gadgets.worlds ui.render accessors combinators literals ;
+USING: accessors combinators kernel literals math math.functions
+math.order math.vectors namespaces opengl opengl.gl sequences
+ui.gadgets ui.gadgets.worlds ui.gestures ;
 IN: opengl.demo-support
 
-CONSTANT: FOV $[ 2.0 sqrt 1+ ]
+CONSTANT: FOV $[ 2.0 sqrt 1 + ]
 CONSTANT: MOUSE-MOTION-SCALE 0.5
 CONSTANT: KEY-ROTATE-STEP 10.0
 
@@ -46,16 +46,16 @@ M: demo-world pref-dim* ( gadget -- dim )
     [ near-plane ] [ far-plane ] [ fov-ratio ] tri [
         nip swap FOV / v*n
         first2 [ -+ ] bi@
-    ] 3keep drop ;
+    ] 2keepd ;
 
 M: demo-world resize-world
     GL_PROJECTION glMatrixMode
     glLoadIdentity
-    [ [ 0 0 ] dip dim>> first2 glViewport ]
+    [ [ { 0 0 } ] dip dim>> gl-viewport ]
     [ demo-world-frustum glFrustum ] bi ;
 
 : demo-world-set-matrix ( gadget -- )
-    GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear
+    flags{ GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT } glClear
     GL_MODELVIEW glMatrixMode
     glLoadIdentity
     [ [ 0.0 0.0 ] dip distance>> neg glTranslatef ]
@@ -88,7 +88,7 @@ M: demo-world resize-world
         over first2 glVertex2d
         dup first pick second glVertex2d
         dup first2 glVertex2d
-        swap first swap second glVertex2d
+        [ first ] [ second ] bi* glVertex2d
     ] do-state ;
 
 demo-world H{
@@ -98,9 +98,8 @@ demo-world H{
     { T{ key-down f f "UP"    } [ KEY-ROTATE-STEP     swap pitch-demo-world ] }
     { T{ key-down f f "="     } [ dup distance-step neg swap zoom-demo-world ] }
     { T{ key-down f f "-"     } [ dup distance-step     swap zoom-demo-world ] }
-    
+
     { T{ button-down f f 1 }    [ drop reset-last-drag-rel ] }
     { T{ drag f 1 }             [ drag-yaw-pitch rot [ pitch-demo-world ] keep yaw-demo-world ] }
     { mouse-scroll              [ scroll-direction get second over distance-step * swap zoom-demo-world ] }
 } set-gestures
-