From 5b965d180a1f536affd51ffc2b51d5e90fbc362d Mon Sep 17 00:00:00 2001 From: David Thompson Date: Tue, 15 Dec 2020 17:39:01 -0500 Subject: Add SDL_GetPerformanceCounter and SDL_GetPerformanceFrequency bindings. --- doc/api.texi | 8 ++++++++ sdl2.scm | 10 ++++++++++ sdl2/bindings.scm | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/doc/api.texi b/doc/api.texi index ed79da5..3c4e645 100644 --- a/doc/api.texi +++ b/doc/api.texi @@ -44,6 +44,14 @@ Return the number of milliseconds since the SDL library was initialized. @end deffn +@deffn {Procedure} sdl-performance-counter +Return the current value of the high resolution counter. +@end deffn + +@deffn {Procedure} sdl-performance-frequency +Return the count per second of the high resolution counter. +@end deffn + @node Window Management @section Window Management diff --git a/sdl2.scm b/sdl2.scm index 53eef74..32d7e84 100644 --- a/sdl2.scm +++ b/sdl2.scm @@ -35,6 +35,8 @@ sdl-init sdl-quit sdl-ticks + sdl-performance-counter + sdl-performance-frequency make-color @@ -94,6 +96,14 @@ upon all exit conditions." initialized." (ffi:sdl-get-ticks)) +(define (sdl-performance-counter) + "Return the current value of the high resolution counter." + (ffi:sdl-get-performance-counter)) + +(define (sdl-performance-frequency) + "Return the count per second of the high resolution counter." + (ffi:sdl-get-performance-frequency)) + ;; SDL_Color (define-record-type (make-color r g b a) diff --git a/sdl2/bindings.scm b/sdl2/bindings.scm index 373f3aa..a9fa17c 100644 --- a/sdl2/bindings.scm +++ b/sdl2/bindings.scm @@ -1007,6 +1007,12 @@ RETURN-TYPE and accept arguments of ARG-TYPES." (define-foreign sdl-get-ticks uint32 "SDL_GetTicks" '()) +(define-foreign sdl-get-performance-counter + uint64 "SDL_GetPerformanceCounter" '()) + +(define-foreign sdl-get-performance-frequency + uint64 "SDL_GetPerformanceFrequency" '()) + ;;; ;;; File I/O -- cgit v1.2.3