]> gitweb.factorcode.org Git - factor.git/commitdiff
rlgl: fix up demo and covabs
authorCapital <CapitalEx@protonmail.com>
Sat, 9 Sep 2023 02:22:56 +0000 (22:22 -0400)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 9 Sep 2023 04:32:55 +0000 (21:32 -0700)
extra/rlgl/demo/demo.factor
extra/rlgl/rlgl.factor

index fbb3946ced629b4a7096fbf3cbb63643e5562dea..f542c1be15f50741eba7798441b541492c815d54 100644 (file)
@@ -11,7 +11,7 @@ IN: rlgl.demo
     call end-drawing ; inline
 
 : with-matrix ( quot -- )
-    rlPushMatrix call rlPopMatrix ; inline
+    rl-push-matrix call rl-pop-matrix ; inline
 
 : while-window-open ( quot -- )
     [ window-should-close not ] swap while ; inline
@@ -30,62 +30,62 @@ CONSTANT:    rotationSpeed 0.2
 
 :: draw-sphere-basic ( color -- )
     16 16 :> ( rings slices )
-    rings 2 + slices 6 * * rlCheckRenderBatchLimit drop
+    rings 2 + slices 6 * * rl-check-render-batch-limit drop
 
-    RL_TRIANGLES rlBegin
-        color [ r>> ] [ g>> ] [ b>> ] [ a>> ] quad rlColor4ub
+    RL_TRIANGLES rl-begin
+        color [ r>> ] [ g>> ] [ b>> ] [ a>> ] quad rl-color4ub
         rings 2 + [0..b) slices [0..b) [| i j |
             270 180 rings 1 + / i * + deg>rad cos j 360 * slices / deg>rad sin *
             270 180 rings 1 + / i * + deg>rad sin
             270 180 rings 1 + / i * + deg>rad cos j 360 * slices / deg>rad cos *
-                        rlVertex3f
+                        rl-vertex3f
 
             270 180 rings 1 + / i 1 + * + deg>rad cos j 1 + 360 * slices / deg>rad sin *
             270 180 rings 1 + / i 1 + * + deg>rad sin
             270 180 rings 1 + / i 1 + * + deg>rad cos j 1 + 360 * slices / deg>rad cos *
-                        rlVertex3f
+                        rl-vertex3f
 
             270 180 rings 1 + / i 1 + * + deg>rad cos j 360 * slices / deg>rad sin *
             270 180 rings 1 + / i 1 + * + deg>rad sin
             270 180 rings 1 + / i 1 + * + deg>rad cos j 360 * slices / deg>rad cos *
-                        rlVertex3f
+                        rl-vertex3f
 
             270 180 rings 1 + / i * + deg>rad cos j 360 * slices / deg>rad sin *
             270 180 rings 1 + / i * + deg>rad sin
             270 180 rings 1 + / i * + deg>rad cos j 360 * slices / deg>rad cos *
-                        rlVertex3f
+                        rl-vertex3f
 
             270 180 rings 1 + / i * + deg>rad cos j 1 + 360 * slices / deg>rad sin *
             270 180 rings 1 + / i * + deg>rad sin
             270 180 rings 1 + / i * + deg>rad cos j 1 + 360 * slices / deg>rad cos *
-                        rlVertex3f
+                        rl-vertex3f
 
             270 180 rings 1 + / i 1 + * + deg>rad cos j 1 + 360 * slices / deg>rad sin *
             270 180 rings 1 + / i 1 + * + deg>rad sin
             270 180 rings 1 + / i 1 + * + deg>rad cos j 1 + 360 * slices / deg>rad cos *
-                        rlVertex3f
+                        rl-vertex3f
         ] cartesian-each
-    rlEnd ;
+    rl-end ;
 
 : draw-sun ( scale -- )
-    dup dup rlScalef GOLD draw-sphere-basic ;
+    dup dup rl-scalef GOLD draw-sphere-basic ;
 
 : draw-moon ( radius rotation orbit-radius orbit-rotation -- )
-    0.0 1.0 0.0 rlRotatef
-        0.0 0.0 rlTranslatef
-    0.0 1.0 0.0 rlRotatef
-    dup dup rlScalef
+    0.0 1.0 0.0 rl-rotatef
+        0.0 0.0 rl-translatef
+    0.0 1.0 0.0 rl-rotatef
+    dup dup rl-scalef
     LIGHTGRAY draw-sphere-basic ;
 
 : draw-earth ( radius rotation -- )
-    0.25 1.0 0.0 rlRotatef dup dup rlScalef
+    0.25 1.0 0.0 rl-rotatef dup dup rl-scalef
     BLUE draw-sphere-basic ;
 
 : draw-earth-and-moon ( moonRadius       moonRotation
                         moonOrbitRadius  moonOrbitRotation
                         earthRadius      earthRotation
                         earthOrbitRadius earthOrbitRotation -- )
-    0.0 1.0 0.0 rlRotatef 0.0 0.0 rlTranslatef
+    0.0 1.0 0.0 rl-rotatef 0.0 0.0 rl-translatef
     [ draw-earth ] with-matrix draw-moon ;
 
 : draw-solar-system ( moonRadius       moonRotation
@@ -136,4 +136,6 @@ CONSTANT:    rotationSpeed 0.2
         ] with-drawing
     ] while-window-open
 
-    close-window ;
\ No newline at end of file
+    close-window ;
+
+MAIN: main
\ No newline at end of file
index 1a31ae4c39a5fa6b5c472a5b4d82105bfd6871f1..49e5a669c41bfaac9e1293eade81e640ec6a01b1 100644 (file)
@@ -1,7 +1,9 @@
 ! Copyright (C) 2023 CapitalEx.
 ! See https://factorcode.org/license.txt for BSD license.
-USING: alien alien.c-types alien.libraries alien.syntax
-classes.struct combinators kernel multiline raylib system ;
+USING: accessors alien alien.c-types alien.libraries
+alien.syntax classes.struct combinators kernel math multiline
+raylib raylib.util system ;
+FROM: alien.c-types => float ;
 IN: rlgl
 
 <<
@@ -108,10 +110,10 @@ STRUCT: rlVertexBuffer
     { vboId        uint[4] }  ! OpenGL Vertex Buffer Objects id ( 4 types of vertex data )
 ;
 
-ARRAY-SLOTS: rlVertexBuffer float _vertices  [ elementCount>> 3 * ] vertices 
-ARRAY-SLOTS: rlVertexBuffer float _texcoords [ elementCount>> 2 * ] texcoords
-ARRAY-SLOTS: rlVertexBuffer uchar _colors    [ elementCount>> 4 * ] colors
-ARRAY-SLOTS: rlVertexBuffer uint  _indices   [ elementCount>> 6 * ] indices
+ARRAY-SLOT: rlVertexBuffer float _vertices  [ elementCount>> 3 * ] vertices 
+ARRAY-SLOT: rlVertexBuffer float _texcoords [ elementCount>> 2 * ] texcoords
+ARRAY-SLOT: rlVertexBuffer uchar _colors    [ elementCount>> 4 * ] colors
+ARRAY-SLOT: rlVertexBuffer uint  _indices   [ elementCount>> 6 * ] indices
 
 ! Draw call type
 ! NOTE: Only texture changes register a new draw, other state-change-related elements are not
@@ -134,8 +136,8 @@ STRUCT: rlRenderBatch
     { currentDepth   float            } ! Current depth value for next draw
 ;
 
-ARRAY-SLOTS: rlRenderBatch rlVertexBuffer _vertexBuffer [ bufferCount>> ] vertexBuffer
-ARRAY-SLOTS: rlRenderBatch rlDrawCall _draws [ drawCounter>> ] draws
+ARRAY-SLOT: rlRenderBatch rlVertexBuffer _vertexBuffer [ bufferCount>> ] vertexBuffer
+ARRAY-SLOT: rlRenderBatch rlDrawCall _draws [ drawCounter>> ] draws
 
 ! OpenGL version
 ENUM: rlGlVersion