Guest User

Untitled

a guest
Feb 15th, 2019
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;; We start at engine.lisp main-loop which calls render in display.lisp:
  2.  
  3. (defun main-loop (core-state)
  4. (initialize-frame-time core-state)
  5. (u:while (running-p core-state)
  6. (iterate-main-loop core-state)))
  7.  
  8. ;; called each real frame, out of this we downsample for physics-frames.
  9. (defun iterate-main-loop (core-state)
  10. (with-continue-restart "First Light"
  11. (fl.input:handle-events (input-data core-state))
  12. (render core-state)
  13. ;; TODO: Remove this later when possible.
  14. (when (fl.input:input-enter-p (input-data core-state) '(:key :escape))
  15. (stop-engine core-state))))
  16.  
  17. (defun render (core-state)
  18. (with-slots (%frame-manager %display %running-p) core-state
  19. (when %running-p
  20. (clear-screen %display)
  21. (execute-flow core-state
  22. :default
  23. 'perform-one-frame
  24. 'entry/perform-one-frame
  25. :come-from-state-name :ef)
  26. (sdl2:gl-swap-window (window %display))
  27. (incf (%frame-count %frame-manager)))))
  28.  
  29. ;; For each frame, which is defined as a single execution of ITERATE-MAIN-LOOP
  30. ;; we run the ordering like this for the steps you specified:
  31. ;;
  32. ;; This entire ordering executes at X frequency, the fastest one.
  33. ;;
  34. ;; 1. fl.input:handle-event is called.
  35. ;; 2. clear screen
  36. ;;
  37. ;; Here is the loop that executes at the physics time frequency, so for
  38. ;; some executions of this entire ordering, this code does not get run.
  39. ;;
  40. ;; 3. loop while enough-time-available-for-physics
  41. ;; NOTE: I think the next two lines should be switched because the update
  42. ;; is actually lagging by one frame in the current ordering!
  43. ;;
  44. ;; on-component-physics-update (whose effects are processed NEXT phys-upd)
  45. ;; <do transform updates over the hierarchy to compute world matrix>
  46. ;; physics-collisions (not implemented yet)
  47. ;;
  48. ;; 4. interpolate transforms from previous to current given time passing.
  49. ;; 5. on-component-update
  50. ;; 6. on-component-render
  51. ;; 7. swap buffers
RAW Paste Data