video: Add SDL_SetWindowFullscreen binding.
authorDavid Thompson <dthompson2@worcester.edu>
Sat, 9 Jan 2016 13:47:39 +0000 (08:47 -0500)
committerDavid Thompson <dthompson2@worcester.edu>
Sat, 9 Jan 2016 13:47:39 +0000 (08:47 -0500)
* sdl2/bindings.scm (sdl-set-window-fullscreen): New procedure.
* sdl2/video.scm (set-window-fullscreen!): New procedure.

sdl2/bindings.scm
sdl2/video.scm

index b6f9431..e394586 100644 (file)
@@ -165,6 +165,9 @@ RETURN-TYPE and accept arguments of ARG-TYPES."
 (define-foreign sdl-set-window-size
   void "SDL_SetWindowSize" (list '* int int))
 
+(define-foreign sdl-set-window-fullscreen
+  int "SDL_SetWindowFullscreen" (list '* uint32))
+
 (define-foreign sdl-gl-create-context
   '* "SDL_GL_CreateContext" '(*))
 
index 8340308..187a5bc 100644 (file)
@@ -50,6 +50,7 @@
             set-window-title!
             set-window-position!
             set-window-size!
+            set-window-fullscreen!
 
             make-gl-context
             gl-context?
@@ -230,6 +231,20 @@ of (width,height) coordinates measured in pixels."
     ((width height)
      (ffi:sdl-set-window-size (unwrap-window window) width height))))
 
+(define* (set-window-fullscreen! window fullscreen? #:key desktop?)
+  "Toggle fullscreen mode on/off for WINDOW.  If FULLSCREEN?,
+fullscreen mode is activated, otherwise it is deactivated.  If
+FULLSCREEN? and DESKTOP?, a special \"fake\" fullscreen mode is used
+that takes the size of the desktop."
+  (let ((flag (cond
+               ((and fullscreen? desktop?)
+                ffi:SDL_WINDOW_FULLSCREEN_DESKTOP)
+               (fullscreen?
+                ffi:SDL_WINDOW_FULLSCREEN)
+               (else 0))))
+    (unless (zero? (ffi:sdl-set-window-fullscreen (unwrap-window window) flag))
+      (sdl-error "set-window-fullscreen!" "failed to change fullscreen mode"))))
+
 \f
 ;;;
 ;;; OpenGL