]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/nehe/5/5.factor
core, basis, extra: Remove DOS line endings from files.
[factor.git] / extra / nehe / 5 / 5.factor
index 9fc19e1cfb873bad834acf2d634ba65e88bb7212..021a9837b937d6f643ff7b40108598eff81f76bc 100644 (file)
-USING: arrays kernel math opengl opengl.gl opengl.glu\r
-opengl.demo-support ui ui.gadgets ui.render ui.pixel-formats\r
-threads accessors calendar literals ;\r
-IN: nehe.5\r
-\r
-TUPLE: nehe5-gadget < gadget rtri rquad thread quit? ;\r
-CONSTANT: width 256\r
-CONSTANT: height 256\r
-: redraw-interval ( -- dt ) 10 milliseconds ;\r
-\r
-: <nehe5-gadget> (  -- gadget )\r
-    nehe5-gadget new\r
-    0.0 >>rtri\r
-    0.0 >>rquad ;\r
-\r
-M: nehe5-gadget draw-gadget* ( gadget -- )\r
-    GL_PROJECTION glMatrixMode\r
-    glLoadIdentity\r
-    45.0 width height / >float 0.1 100.0 gluPerspective\r
-    GL_MODELVIEW glMatrixMode\r
-    glLoadIdentity\r
-    GL_SMOOTH glShadeModel\r
-    0.0 0.0 0.0 0.0 glClearColor\r
-    1.0 glClearDepth\r
-    GL_DEPTH_TEST glEnable\r
-    GL_LEQUAL glDepthFunc\r
-    GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST glHint\r
-    GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear\r
-    glLoadIdentity\r
-    -1.5 0.0 -6.0 glTranslatef\r
-    dup rtri>> 0.0 1.0 0.0 glRotatef\r
-\r
-    GL_TRIANGLES [\r
-        1.0 0.0 0.0 glColor3f\r
-        0.0 1.0 0.0 glVertex3f\r
-        0.0 1.0 0.0 glColor3f\r
-        -1.0 -1.0 1.0 glVertex3f\r
-        0.0 0.0 1.0 glColor3f\r
-        1.0 -1.0 1.0 glVertex3f\r
-\r
-        1.0 0.0 0.0 glColor3f\r
-        0.0 1.0 0.0 glVertex3f\r
-        0.0 0.0 1.0 glColor3f\r
-        1.0 -1.0 1.0 glVertex3f\r
-        0.0 1.0 0.0 glColor3f\r
-        1.0 -1.0 -1.0 glVertex3f\r
-\r
-        1.0 0.0 0.0 glColor3f\r
-        0.0 1.0 0.0 glVertex3f\r
-        0.0 1.0 0.0 glColor3f\r
-        1.0 -1.0 -1.0 glVertex3f\r
-        0.0 0.0 1.0 glColor3f\r
-        -1.0 -1.0 -1.0 glVertex3f\r
-\r
-        1.0 0.0 0.0 glColor3f\r
-        0.0 1.0 0.0 glVertex3f\r
-        0.0 0.0 1.0 glColor3f\r
-        -1.0 -1.0 -1.0 glVertex3f\r
-        0.0 1.0 0.0 glColor3f\r
-        -1.0 -1.0 1.0 glVertex3f\r
-    ] do-state\r
-\r
-    glLoadIdentity\r
-\r
-    1.5 0.0 -7.0 glTranslatef\r
-    dup rquad>> 1.0 0.0 0.0 glRotatef\r
-    GL_QUADS [\r
-        0.0 1.0 0.0 glColor3f\r
-        1.0 1.0 -1.0 glVertex3f\r
-        -1.0 1.0 -1.0 glVertex3f\r
-        -1.0 1.0 1.0 glVertex3f\r
-        1.0 1.0 1.0 glVertex3f\r
-\r
-        1.0 0.5 0.0 glColor3f\r
-        1.0 -1.0 1.0 glVertex3f\r
-        -1.0 -1.0 1.0 glVertex3f\r
-        -1.0 -1.0 -1.0 glVertex3f\r
-        1.0 -1.0 -1.0 glVertex3f\r
-\r
-        1.0 0.0 0.0 glColor3f\r
-        1.0 1.0 1.0 glVertex3f\r
-        -1.0 1.0 1.0 glVertex3f\r
-        -1.0 -1.0 1.0 glVertex3f\r
-        1.0 -1.0 1.0 glVertex3f\r
-\r
-        1.0 1.0 0.0 glColor3f\r
-        1.0 -1.0 -1.0 glVertex3f\r
-        -1.0 -1.0 -1.0 glVertex3f\r
-        -1.0 1.0 -1.0 glVertex3f\r
-        1.0 1.0 -1.0 glVertex3f\r
-\r
-        0.0 0.0 1.0 glColor3f\r
-        -1.0 1.0 1.0 glVertex3f\r
-        -1.0 1.0 -1.0 glVertex3f\r
-        -1.0 -1.0 -1.0 glVertex3f\r
-        -1.0 -1.0 1.0 glVertex3f\r
-\r
-        1.0 0.0 1.0 glColor3f\r
-        1.0 1.0 -1.0 glVertex3f\r
-        1.0 1.0 1.0 glVertex3f\r
-        1.0 -1.0 1.0 glVertex3f\r
-        1.0 -1.0 -1.0 glVertex3f\r
-    ] do-state\r
-    [ 0.2 + ] change-rtri\r
-    [ 0.15 - ] change-rquad drop ;\r
-\r
-: nehe5-update-thread ( gadget -- )\r
-    dup quit?>> [\r
-        drop\r
-    ] [\r
-        redraw-interval sleep\r
-        dup relayout-1\r
-        nehe5-update-thread\r
-    ] if ;\r
-\r
-M: nehe5-gadget graft* ( gadget -- )\r
-    f >>quit?\r
-    [ nehe5-update-thread ] curry in-thread ;\r
-\r
-M: nehe5-gadget ungraft* ( gadget -- )\r
-    t >>quit? drop ;\r
-\r
-MAIN-WINDOW: run5\r
-    {\r
-        { title "NeHe Tutorial 5" }\r
-        { pref-dim { $ width $ height } }\r
-        { pixel-format-attributes {\r
-            windowed\r
-            double-buffered\r
-            T{ depth-bits { value 16 } }\r
-        } }\r
-    }\r
-    <nehe5-gadget> >>gadgets ;\r
+USING: arrays kernel math opengl opengl.gl opengl.glu
+opengl.demo-support ui ui.gadgets ui.render ui.pixel-formats
+threads accessors calendar literals ;
+IN: nehe.5
+
+TUPLE: nehe5-gadget < gadget rtri rquad thread quit? ;
+CONSTANT: width 256
+CONSTANT: height 256
+: redraw-interval ( -- dt ) 10 milliseconds ;
+
+: <nehe5-gadget> (  -- gadget )
+    nehe5-gadget new
+    0.0 >>rtri
+    0.0 >>rquad ;
+
+M: nehe5-gadget draw-gadget* ( gadget -- )
+    GL_PROJECTION glMatrixMode
+    glLoadIdentity
+    45.0 width height / >float 0.1 100.0 gluPerspective
+    GL_MODELVIEW glMatrixMode
+    glLoadIdentity
+    GL_SMOOTH glShadeModel
+    0.0 0.0 0.0 0.0 glClearColor
+    1.0 glClearDepth
+    GL_DEPTH_TEST glEnable
+    GL_LEQUAL glDepthFunc
+    GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST glHint
+    GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear
+    glLoadIdentity
+    -1.5 0.0 -6.0 glTranslatef
+    dup rtri>> 0.0 1.0 0.0 glRotatef
+
+    GL_TRIANGLES [
+        1.0 0.0 0.0 glColor3f
+        0.0 1.0 0.0 glVertex3f
+        0.0 1.0 0.0 glColor3f
+        -1.0 -1.0 1.0 glVertex3f
+        0.0 0.0 1.0 glColor3f
+        1.0 -1.0 1.0 glVertex3f
+
+        1.0 0.0 0.0 glColor3f
+        0.0 1.0 0.0 glVertex3f
+        0.0 0.0 1.0 glColor3f
+        1.0 -1.0 1.0 glVertex3f
+        0.0 1.0 0.0 glColor3f
+        1.0 -1.0 -1.0 glVertex3f
+
+        1.0 0.0 0.0 glColor3f
+        0.0 1.0 0.0 glVertex3f
+        0.0 1.0 0.0 glColor3f
+        1.0 -1.0 -1.0 glVertex3f
+        0.0 0.0 1.0 glColor3f
+        -1.0 -1.0 -1.0 glVertex3f
+
+        1.0 0.0 0.0 glColor3f
+        0.0 1.0 0.0 glVertex3f
+        0.0 0.0 1.0 glColor3f
+        -1.0 -1.0 -1.0 glVertex3f
+        0.0 1.0 0.0 glColor3f
+        -1.0 -1.0 1.0 glVertex3f
+    ] do-state
+
+    glLoadIdentity
+
+    1.5 0.0 -7.0 glTranslatef
+    dup rquad>> 1.0 0.0 0.0 glRotatef
+    GL_QUADS [
+        0.0 1.0 0.0 glColor3f
+        1.0 1.0 -1.0 glVertex3f
+        -1.0 1.0 -1.0 glVertex3f
+        -1.0 1.0 1.0 glVertex3f
+        1.0 1.0 1.0 glVertex3f
+
+        1.0 0.5 0.0 glColor3f
+        1.0 -1.0 1.0 glVertex3f
+        -1.0 -1.0 1.0 glVertex3f
+        -1.0 -1.0 -1.0 glVertex3f
+        1.0 -1.0 -1.0 glVertex3f
+
+        1.0 0.0 0.0 glColor3f
+        1.0 1.0 1.0 glVertex3f
+        -1.0 1.0 1.0 glVertex3f
+        -1.0 -1.0 1.0 glVertex3f
+        1.0 -1.0 1.0 glVertex3f
+
+        1.0 1.0 0.0 glColor3f
+        1.0 -1.0 -1.0 glVertex3f
+        -1.0 -1.0 -1.0 glVertex3f
+        -1.0 1.0 -1.0 glVertex3f
+        1.0 1.0 -1.0 glVertex3f
+
+        0.0 0.0 1.0 glColor3f
+        -1.0 1.0 1.0 glVertex3f
+        -1.0 1.0 -1.0 glVertex3f
+        -1.0 -1.0 -1.0 glVertex3f
+        -1.0 -1.0 1.0 glVertex3f
+
+        1.0 0.0 1.0 glColor3f
+        1.0 1.0 -1.0 glVertex3f
+        1.0 1.0 1.0 glVertex3f
+        1.0 -1.0 1.0 glVertex3f
+        1.0 -1.0 -1.0 glVertex3f
+    ] do-state
+    [ 0.2 + ] change-rtri
+    [ 0.15 - ] change-rquad drop ;
+
+: nehe5-update-thread ( gadget -- )
+    dup quit?>> [
+        drop
+    ] [
+        redraw-interval sleep
+        dup relayout-1
+        nehe5-update-thread
+    ] if ;
+
+M: nehe5-gadget graft* ( gadget -- )
+    f >>quit?
+    [ nehe5-update-thread ] curry in-thread ;
+
+M: nehe5-gadget ungraft* ( gadget -- )
+    t >>quit? drop ;
+
+MAIN-WINDOW: run5
+    {
+        { title "NeHe Tutorial 5" }
+        { pref-dim { $ width $ height } }
+        { pixel-format-attributes {
+            windowed
+            double-buffered
+            T{ depth-bits { value 16 } }
+        } }
+    }
+    <nehe5-gadget> >>gadgets ;