From b237543e4287be8bfbcd6bfc392aa81e305d7aec Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 30 Sep 2023 17:59:51 -0400 Subject: video: Add SDL_GL_MakeCurrent binding. --- sdl2/bindings.scm | 3 +++ sdl2/video.scm | 7 +++++++ 2 files changed, 10 insertions(+) (limited to 'sdl2') diff --git a/sdl2/bindings.scm b/sdl2/bindings.scm index cb8dd97..058e342 100644 --- a/sdl2/bindings.scm +++ b/sdl2/bindings.scm @@ -234,6 +234,9 @@ RETURN-TYPE and accept arguments of ARG-TYPES." (define-foreign sdl-gl-delete-context void "SDL_GL_DeleteContext" '(*)) +(define-foreign sdl-gl-make-current + void "SDL_GL_MakeCurrent" '(* *)) + (define-foreign sdl-gl-swap-window void "SDL_GL_SwapWindow" '(*)) diff --git a/sdl2/video.scm b/sdl2/video.scm index 0db5314..7991697 100644 --- a/sdl2/video.scm +++ b/sdl2/video.scm @@ -63,6 +63,7 @@ delete-gl-context! call-with-gl-context swap-gl-window + gl-context-make-current! set-gl-attribute! set-gl-swap-interval!)) @@ -292,6 +293,12 @@ that takes the size of the desktop." (sdl-error "make-gl-context" "failed to create OpenGL context") (wrap-gl-context ptr)))) +(define (gl-context-make-current! window context) + "Make CONTEXT the current context for rendering to WINDOW in the +current thread." + (unless (zero? (ffi:sdl-gl-make-current (unwrap-window window) (unwrap-gl-context context))) + (sdl-error "gl-make-current" "failed to set current GL context"))) + (define (delete-gl-context! context) "Delete CONTEXT, an OpenGL context object." (ffi:sdl-gl-delete-context (unwrap-gl-context context))) -- cgit v1.2.3