From 3678af541ed14fe679b1e22f7c07c8bfec9c8265 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 21 Jul 2013 22:43:54 -0400 Subject: Add optional resizable paramter to open-window. --- 2d/window.scm | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to '2d/window.scm') diff --git a/2d/window.scm b/2d/window.scm index 5f82df1..334e709 100644 --- a/2d/window.scm +++ b/2d/window.scm @@ -37,24 +37,26 @@ the rest of the framework." ;; Enable unicode key events (SDL:enable-unicode #t)) -(define* (open-window width height #:optional #:key (depth 24) (title "guile-2d")) +(define* (open-window width height #:optional #:key + (depth 24) (title "guile-2d") (resizable #f)) "Creates the game window with the specified dimensions and initializes OpenGL state." - ;; Open SDL window in OpenGL mode. - (SDL:set-video-mode width height depth 'opengl) - (SDL:set-caption title) - ;; Initialize OpenGL orthographic view - (gl-viewport 0 0 width height) - (set-gl-matrix-mode (matrix-mode projection)) - (gl-load-identity) - (gl-ortho 0 width height 0 -1 1) - (set-gl-matrix-mode (matrix-mode modelview)) - (gl-load-identity) - ;; Enable texturing and alpha blending - (gl-enable (enable-cap texture-2d)) - (gl-enable (enable-cap blend)) - (set-gl-blend-function (blending-factor-src src-alpha) - (blending-factor-dest one-minus-src-alpha))) + (let ((flags (if resizable '(opengl resizable) 'opengl))) + ;; Open SDL window in OpenGL mode. + (SDL:set-video-mode width height depth flags) + (SDL:set-caption title) + ;; Initialize OpenGL orthographic view + (gl-viewport 0 0 width height) + (set-gl-matrix-mode (matrix-mode projection)) + (gl-load-identity) + (gl-ortho 0 width height 0 -1 1) + (set-gl-matrix-mode (matrix-mode modelview)) + (gl-load-identity) + ;; Enable texturing and alpha blending + (gl-enable (enable-cap texture-2d)) + (gl-enable (enable-cap blend)) + (set-gl-blend-function (blending-factor-src src-alpha) + (blending-factor-dest one-minus-src-alpha)))) (define (close-window) "Closes the game window and cleans up. This procedure is typically -- cgit v1.2.3