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
:: 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
] with-drawing
] while-window-open
- close-window ;
\ No newline at end of file
+ close-window ;
+
+MAIN: main
\ No newline at end of file
! 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
<<
{ 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
{ 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