Remove "sdl-" prefix from symbols in window module.
authorDavid Thompson <dthompson2@worcester.edu>
Mon, 14 Dec 2015 17:03:30 +0000 (12:03 -0500)
committerDavid Thompson <dthompson2@worcester.edu>
Mon, 14 Dec 2015 17:03:30 +0000 (12:03 -0500)
examples/hello.scm
sdl2/render.scm
sdl2/video.scm

index 3075102..1f98669 100644 (file)
@@ -24,7 +24,7 @@
 
 (sdl-init)
 
-(define window (make-sdl-window))
+(define window (make-window))
 (define ren (make-renderer window))
 (define surface (load-bmp "hello.bmp"))
 (define texture (surface->texture ren surface))
@@ -33,5 +33,6 @@
 (render-copy ren texture)
 (present-renderer ren)
 (sleep 2)
-(close-sdl-window! window)
+(close-window! window)
+(delete-renderer! ren)
 (sdl-quit)
index b0a5b57..8c34d60 100644 (file)
@@ -69,7 +69,7 @@ FLAGS are:
 * accelerated, to use hardware acceleration
 * vsync, to synchronize rendering with the monitor's refresh rate
 * texture, for render to texture support"
-  (let ((ptr (ffi:sdl-create-renderer ((@@ (sdl2 video) unwrap-sdl-window)
+  (let ((ptr (ffi:sdl-create-renderer ((@@ (sdl2 video) unwrap-window)
                                        window)
                                       -1 ; pick driver automatically
                                       (renderer-flags->bitmask flags))))
index f7697fc..e4d6d6c 100644 (file)
   #:use-module (system foreign)
   #:use-module ((sdl2 bindings) #:prefix ffi:)
   #:use-module (sdl2)
-  #:export (sdl-window?
-            make-sdl-window
-            close-sdl-window!
-            call-with-sdl-window
-            sdl-window-title
-            sdl-window-size
-            sdl-window-position
-            sdl-window-id
-            id->sdl-window
-            hide-sdl-window!
-            show-sdl-window!
-            maximize-sdl-window!
-            minimize-sdl-window!
-            raise-sdl-window!
-            restore-sdl-window!
-            set-sdl-window-border!
-            set-sdl-window-title!
-            set-sdl-window-position!
-            set-sdl-window-size!
+  #:export (window?
+            make-window
+            close-window!
+            call-with-window
+            window-title
+            window-size
+            window-position
+            window-id
+            id->window
+            hide-window!
+            show-window!
+            maximize-window!
+            minimize-window!
+            raise-window!
+            restore-window!
+            set-window-border!
+            set-window-title!
+            set-window-position!
+            set-window-size!
 
             make-gl-context
             gl-context?
             delete-gl-context!
             call-with-gl-context
-            swap-gl-sdl-window))
+            swap-gl-window))
 
 \f
 ;;;
 ;;; Windows
 ;;;
 
-(define-wrapped-pointer-type <sdl-window>
-  sdl-window?
-  wrap-sdl-window unwrap-sdl-window
+(define-wrapped-pointer-type <window>
+  window?
+  wrap-window unwrap-window
   (lambda (window port)
-    (format port "#<sdl-window id: ~s title: ~s size: ~s position: ~s>"
-            (sdl-window-id window)
-            (sdl-window-title window)
-            (sdl-window-size window)
-            (sdl-window-position window))))
+    (format port "#<window id: ~s title: ~s size: ~s position: ~s>"
+            (window-id window)
+            (window-title window)
+            (window-size window)
+            (window-position window))))
 
-(define* (make-sdl-window #:key (title "Guile SDL2 Window")
+(define* (make-window #:key (title "Guile SDL2 Window")
                           (position '(0 0)) (size '(640 480))
                           (maximize? #f) (minimize? #f)
                           (show? #t) (resizable? #f)
@@ -120,103 +120,103 @@ the form '(x y)', where each coordinate is measured in pixels."
                                      (x size) (y size)
                                      flags)))
     (if (null-pointer? ptr)
-        (sdl-error "make-sdl-window" "failed to create window")
-        (wrap-sdl-window ptr))))
+        (sdl-error "make-window" "failed to create window")
+        (wrap-window ptr))))
 
-(define (close-sdl-window! window)
+(define (close-window! window)
   "Close WINDOW."
-  (ffi:sdl-destroy-window (unwrap-sdl-window window)))
+  (ffi:sdl-destroy-window (unwrap-window window)))
 
-(define (call-with-sdl-window args proc)
+(define (call-with-window args proc)
   "Call PROC with a new window defined by ARGS, a list of keyword
-arguments accepted by 'make-sdl-window', and close it when PROC
+arguments accepted by 'make-window', and close it when PROC
 returns or otherwise exits."
-  (let ((window (apply make-sdl-window args)))
+  (let ((window (apply make-window args)))
     (dynamic-wind
       (const #t)
       (lambda () (proc window))
       (lambda ()
-        (close-sdl-window! window)))))
+        (close-window! window)))))
 
-(define (sdl-window-title window)
+(define (window-title window)
   "Return the title for WINDOW."
-  (pointer->string (ffi:sdl-get-window-title (unwrap-sdl-window window))))
+  (pointer->string (ffi:sdl-get-window-title (unwrap-window window))))
 
 (define (%get-coords window proc)
   (let ((bv (make-bytevector (* 2 (sizeof int)) 0)))
-    (proc (unwrap-sdl-window window)
+    (proc (unwrap-window window)
           (bytevector->pointer bv)
           (bytevector->pointer bv (sizeof int)))
     (bytevector->sint-list bv (native-endianness) (sizeof int))))
 
-(define (sdl-window-size window)
+(define (window-size window)
   "Return the dimensions of WINDOW."
   (%get-coords window ffi:sdl-get-window-size))
 
-(define (sdl-window-position window)
+(define (window-position window)
   "Return the position of WINDOW on the display."
   (%get-coords window ffi:sdl-get-window-position))
 
-(define (sdl-window-id window)
+(define (window-id window)
   "Return the numeric ID of WINDOW."
-  (ffi:sdl-get-window-id (unwrap-sdl-window window)))
+  (ffi:sdl-get-window-id (unwrap-window window)))
 
-(define (id->sdl-window id)
+(define (id->window id)
   "Return the window corresponding to ID, a positive integer, or #f if
 there is no such window."
   (let ((ptr (ffi:sdl-get-window-from-id id)))
     (if (null-pointer? ptr)
         #f
-        (wrap-sdl-window ptr))))
+        (wrap-window ptr))))
 
-(define (hide-sdl-window! window)
+(define (hide-window! window)
   "Hide WINDOW."
-  (ffi:sdl-hide-window (unwrap-sdl-window window)))
+  (ffi:sdl-hide-window (unwrap-window window)))
 
-(define (show-sdl-window! window)
+(define (show-window! window)
   "Show WINDOW and focus on it."
-  (ffi:sdl-show-window (unwrap-sdl-window window)))
+  (ffi:sdl-show-window (unwrap-window window)))
 
-(define (maximize-sdl-window! window)
+(define (maximize-window! window)
   "Make WINDOW as large as possible."
-  (ffi:sdl-maximize-window (unwrap-sdl-window window)))
+  (ffi:sdl-maximize-window (unwrap-window window)))
 
-(define (minimize-sdl-window! window)
+(define (minimize-window! window)
   "Shrink WINDOW to an iconic representation."
-  (ffi:sdl-minimize-window (unwrap-sdl-window window)))
+  (ffi:sdl-minimize-window (unwrap-window window)))
 
-(define (raise-sdl-window! window)
+(define (raise-window! window)
   "Raise WINDOW above all other windows and set input focus."
-  (ffi:sdl-raise-window (unwrap-sdl-window window)))
+  (ffi:sdl-raise-window (unwrap-window window)))
 
-(define (restore-sdl-window! window)
+(define (restore-window! window)
   "Restore the size and position of a minimized or maximized WINDOW."
-  (ffi:sdl-restore-window (unwrap-sdl-window window)))
+  (ffi:sdl-restore-window (unwrap-window window)))
 
-(define (set-sdl-window-border! window border?)
+(define (set-window-border! window border?)
   "When BORDER?, draw the usual border around WINDOW, otherwise remove
 the border."
-  (ffi:sdl-set-window-bordered (unwrap-sdl-window window)
+  (ffi:sdl-set-window-bordered (unwrap-window window)
                                (ffi:boolean->sdl-bool border?)))
 
-(define (set-sdl-window-title! window title)
+(define (set-window-title! window title)
   "Set the title of WINDOW to the string TITLE."
-  (ffi:sdl-set-window-title (unwrap-sdl-window window)
+  (ffi:sdl-set-window-title (unwrap-window window)
                             (string->pointer title)))
 
-(define (set-sdl-window-position! window position)
+(define (set-window-position! window position)
   "Set the position of WINDOW to POSITION, a two-element list of (x,y)
 coordinates measured in pixels."
   (match position
     ((x y)
-     (ffi:sdl-set-window-position (unwrap-sdl-window window) x y))))
+     (ffi:sdl-set-window-position (unwrap-window window) x y))))
 
-(define (set-sdl-window-size! window size)
+(define (set-window-size! window size)
   "Set the dimensions of WINDOW to SIZE, a two-element list
 of (width,height) coordinates measured in pixels."
   (match size
     ((width height)
-     (ffi:sdl-set-window-size (unwrap-sdl-window window) width height))))
+     (ffi:sdl-set-window-size (unwrap-window window) width height))))
 
 \f
 ;;;
@@ -232,7 +232,7 @@ of (width,height) coordinates measured in pixels."
 
 (define (make-gl-context window)
   "Create an OpenGL context for WINDOW."
-  (let ((ptr (ffi:sdl-gl-create-context (unwrap-sdl-window window))))
+  (let ((ptr (ffi:sdl-gl-create-context (unwrap-window window))))
     (if (null-pointer? ptr)
         (sdl-error "make-gl-context" "failed to create OpenGL context")
         (wrap-gl-context ptr))))
@@ -251,6 +251,6 @@ the context when PROC returns or otherwise exits.."
       (lambda ()
         (delete-gl-context! context)))))
 
-(define (swap-gl-sdl-window window)
+(define (swap-gl-window window)
   "Update WINDOW with OpenGL rendering."
-  (ffi:sdl-gl-swap-window (unwrap-sdl-window window)))
+  (ffi:sdl-gl-swap-window (unwrap-window window)))