From 2318ab37794d9d15470238b2f6b7d36a36052276 Mon Sep 17 00:00:00 2001 From: Capital Date: Fri, 8 Sep 2023 22:22:56 -0400 Subject: [PATCH] rlgl: fix up demo and covabs --- extra/rlgl/demo/demo.factor | 40 +++++++++++++++++++------------------ extra/rlgl/rlgl.factor | 18 +++++++++-------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/extra/rlgl/demo/demo.factor b/extra/rlgl/demo/demo.factor index fbb3946ced..f542c1be15 100644 --- a/extra/rlgl/demo/demo.factor +++ b/extra/rlgl/demo/demo.factor @@ -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 diff --git a/extra/rlgl/rlgl.factor b/extra/rlgl/rlgl.factor index 1a31ae4c39..49e5a669c4 100644 --- a/extra/rlgl/rlgl.factor +++ b/extra/rlgl/rlgl.factor @@ -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 -- 2.34.1