]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/model-viewer/model-viewer.factor
use radix literals
[factor.git] / extra / model-viewer / model-viewer.factor
index 22a80a136e6bdbe3c60cbf0793e71d545080c4c8..72d603540d78bfe0fcd941904d4a0ef12f9a1ac7 100644 (file)
@@ -8,10 +8,9 @@ io io.encodings.ascii io.files io.files.temp kernel locals math
 math.matrices math.vectors.simd math.parser math.vectors
 method-chains namespaces sequences splitting threads ui ui.gadgets
 ui.gadgets.worlds ui.pixel-formats specialized-arrays
-specialized-vectors literals fry
-sequences.deep destructors math.bitwise opengl.gl
+specialized-vectors fry sequences.deep destructors math.bitwise opengl.gl
 game.models game.models.obj game.models.loader game.models.collada
-prettyprint images.tga ;
+prettyprint images.tga literals ;
 FROM: alien.c-types => float ;
 SPECIALIZED-ARRAY: float
 SPECIALIZED-VECTOR: uint
@@ -89,12 +88,18 @@ TUPLE: vbo
     index-buffer index-count vertex-format texture bump ka ;
 
 : white-image ( -- image )
-    { 1 1 } BGR ubyte-components f
-    B{ 255 255 255 } image boa ;
+    <image>
+        { 1 1 } >>dim
+        BGR >>component-order
+        ubyte-components >>component-type
+        B{ 255 255 255 } >>bitmap ;
 
 : up-image ( -- image )
-    { 1 1 } BGR ubyte-components f
-    B{ 0 0 0 } image boa ;
+    <image>
+        { 1 1 } >>dim
+        BGR >>component-order
+        ubyte-components >>component-type
+        B{ 0 0 0 } >>bitmap ;
         
 : make-texture ( pathname alt -- texture )
     swap [ nip load-image ] [ ] if*
@@ -130,7 +135,7 @@ TUPLE: vbo
         [
             [
                 [ vertex-buffer>> obj-program <program-instance> ]
-                [ vertex-format>> ] bi buffer>vertex-array
+                [ vertex-format>> ] bi <vertex-array*>
             ] map >>vertex-arrays drop
         ]
         [
@@ -163,10 +168,10 @@ TUPLE: vbo
 : clear-screen ( -- )
     0 0 0 0 glClearColor 
     1 glClearDepth
-    HEX: ffffffff glClearStencil
-    { GL_COLOR_BUFFER_BIT
+    0xffffffff glClearStencil
+    flags{ GL_COLOR_BUFFER_BIT
       GL_DEPTH_BUFFER_BIT
-      GL_STENCIL_BUFFER_BIT } flags glClear ;
+      GL_STENCIL_BUFFER_BIT } glClear ;
     
 : draw-model ( world -- )
     clear-screen
@@ -194,7 +199,7 @@ M: model-world wasd-far-plane drop 1024.0 ;
 M: model-world begin-game-world
     init-gpu
     { 0.0 0.0 2.0 } 0 0 set-wasd-view
-    [ <model-state> [ fill-model-state ] keep ] [ (>>model-state) ] bi ;
+    [ <model-state> [ fill-model-state ] keep ] [ model-state<< ] bi ;
 M: model-world apply-world-attributes
     {
         [ model-path>> >>model-path ]
@@ -212,7 +217,7 @@ M: model-world apply-world-attributes
              { windowed double-buffered }
            }
            { pref-dim { 1024 768 } }
-           { tick-interval-micros 16666 }
+           { tick-interval-nanos $[ 60 fps ] }
            { use-game-input? t }
            { model-path model-path }
         }