Browse Source

Add time functions to SDL

master
Macoy Madson 9 months ago
parent
commit
bf2dd0c5fa
  1. 15
      src/SDL.cake

15
src/SDL.cake

@ -184,6 +184,21 @@
(SDL_Log "--- %s at %f seconds\n" label delta-time))
;; This should be thread-safe assuming set-startup-time-now is only called once
(var s-startup-num-perf-ticks Uint64 0)
(defun set-startup-time-now ()
(set s-startup-num-perf-ticks (SDL_GetPerformanceCounter)))
(defun get-time-since-startup (&return float)
(var performance-num-ticks-per-second (const Uint64) (SDL_GetPerformanceFrequency))
(var current-counter-ticks Uint64 (SDL_GetPerformanceCounter))
(var frame-diff-ticks Uint64 (- current-counter-ticks s-startup-num-perf-ticks))
(var delta-time float (/ frame-diff-ticks
(type-cast performance-num-ticks-per-second float)))
(return delta-time))
;;
;; Input
;;

Loading…
Cancel
Save