Guest User

Untitled

a guest
Feb 15th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  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 this ordering should be considered more carefully
  42. ;; to see if we're actually causing a single frame delay or skewing
  43. ;; the physics we're updating versus the physics state we're using for
  44. ;; collisions.
  45. ;;
  46. ;; on-component-physics-update
  47. ;; <do transform updates over the hierarchy to compute world matrix>
  48. ;; physics-collisions (not implemented yet)
  49. ;;
  50. ;; 4. interpolate transforms from previous to current given time passing.
  51. ;; 5. on-component-update
  52. ;; 6. on-component-render
  53. ;; 7. swap buffers
Add Comment
Please, Sign In to add comment