a guest Feb 15th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- ;; We start at engine.lisp main-loop which calls render in display.lisp:
- (defun main-loop (core-state)
- (initialize-frame-time core-state)
- (u:while (running-p core-state)
- (iterate-main-loop core-state)))
- ;; called each real frame, out of this we downsample for physics-frames.
- (defun iterate-main-loop (core-state)
- (with-continue-restart "First Light"
- (fl.input:handle-events (input-data core-state))
- (render core-state)
- ;; TODO: Remove this later when possible.
- (when (fl.input:input-enter-p (input-data core-state) '(:key :escape))
- (stop-engine core-state))))
- (defun render (core-state)
- (with-slots (%frame-manager %display %running-p) core-state
- (when %running-p
- (clear-screen %display)
- (execute-flow core-state
- :come-from-state-name :ef)
- (sdl2:gl-swap-window (window %display))
- (incf (%frame-count %frame-manager)))))
- ;; For each frame, which is defined as a single execution of ITERATE-MAIN-LOOP
- ;; we run the ordering like this for the steps you specified:
- ;; This entire ordering executes at X frequency, the fastest one.
- ;; 1. fl.input:handle-event is called.
- ;; 2. clear screen
- ;; Here is the loop that executes at the physics time frequency, so for
- ;; some executions of this entire ordering, this code does not get run.
- ;; 3. loop while enough-time-available-for-physics
- ;; NOTE: I think the next two lines should be switched because the update
- ;; is actually lagging by one frame in the current ordering!
- ;; on-component-physics-update (whose effects are processed NEXT phys-upd)
- ;; <do transform updates over the hierarchy to compute world matrix>
- ;; physics-collisions (not implemented yet)
- ;; 4. interpolate transforms from previous to current given time passing.
- ;; 5. on-component-update
- ;; 6. on-component-render
- ;; 7. swap buffers
RAW Paste Data