Update docs to include render queue functions

This commit is contained in:
BirDt_ 2026-04-04 14:16:53 +08:00
parent 44d078c310
commit 42df36534e

View file

@ -72,6 +72,10 @@ The ~games~ folder contains various sample games made with Imugi.
~systems~ is a list, which contains all lists to be executed on each frame.
~event-buses~ is an SRFI-69 hash table, which contains hash tables keyed by the event bus name. Each hash table in ~event-buses~ keeps track of individual event records keyed by action names.
~render-queues~ is an SRFI-69 hash table, which contains lists keyed by the render queue name. Each item in these lists is a pair, where the first element is the layer of the drawing and the second is a thunk that gets called during the render.
~render-priority~ is an association list, where the first element of each pair is a render queue name from the ~render-queues~ hash table, and the second element is the drawing mode (a symbol which is either ~screen~, ~2d~, or ~3d~). The order of elements in the ~render-priority~ association list determines the order in which the render-queues are evaluated, with the first queue name in the list being the first queue to evaluate.
*** Entities
#+begin_src scheme
(create-named-entity id . components)
@ -123,8 +127,26 @@ Event buses are added and remove immediately, without queuing.
Functions for creating and fetching events. ~bus~ must be a symbol referencing a bus name, ~action~ must be a symbol referencing the name of the action, and ~event~ must be a record.
~peek-event~ returns the event record but keeps the event in the event bus. ~pop-event~ returns the event record and removes it from the event bus.
*** Frame Generation & Game Loop
#+begin_src
*** Frame Generation, Render Queues, and Game Loop
#+begin_src scheme
(register-render-queue queue-name drawing)
#+end_src
Create a new render queue in ~render-queues~, where ~queue-name~ is the queue name symbol and ~drawing~ is the drawing mode (either ~screen~, ~2d~, or ~3d~). Render queues created this way are automatically placed at the front of the ~render-priority~ assocation list.
#+begin_src scheme
(push-render-object queue-name layer thunk)
#+end_src
Adds a thunk to the given render queue name at the given layer. ~queue-name~ must be a symbol, ~layer~ must be an integer, and ~thunk~ must be a zero-argument procedure.
#+begin_src scheme
(evaluate-render-queue queue-name mode)
(perform-render)
#+end_src
Functions for evaluating the render queues. ~evaluate-render-queue~ evaluates a single queue where ~queue-name~ is a symbol corresponding to a queue in the ~render-queues~, and ~mode~ is a drawing mode symbol (either ~screen~, ~2d~, or ~3d~). The given queue is cleared after evaluation.
~perform-render~ iterates the ~render-priority~ association list and calls ~evaluate-render-queue~ on each queue in order with the appropriate mode.
#+begin_src scheme
*clear-color*
#+end_src
~*clear-color*~ is a parameter which expects a u8vector corresponding to a Raylib color.
@ -137,7 +159,8 @@ Functions for creating and fetching events. ~bus~ must be a symbol referencing a
#+begin_src scheme
(next-frame)
#+end_src
~(next-frame)~ is a frame generation function. When called, it resolves all queues, then beings drawing. It then clears the window background to the ~*clear-color*~, and then executes all systems.
~(next-frame)~ is a frame generation function. When called, it resolves all queues, then executes all systems, then finally performs the render of the next frame.
*** Window Functions
#+begin_src
*window-size*