diff options
Diffstat (limited to '2d')
-rw-r--r-- | 2d/game.scm | 7 | ||||
-rw-r--r-- | 2d/window.scm | 9 |
2 files changed, 9 insertions, 7 deletions
diff --git a/2d/game.scm b/2d/game.scm index 847defa..e8bcfaa 100644 --- a/2d/game.scm +++ b/2d/game.scm @@ -31,6 +31,7 @@ #:use-module (2d game) #:use-module (2d signals) #:use-module (2d vector2) + #:use-module (2d window) #:export (ticks-per-second tick-interval paused-agenda @@ -69,6 +70,12 @@ (define (draw dt alpha) "Render a frame." + (let ((width (signal-ref window-width)) + (height (signal-ref window-height))) + (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) (gl-clear (clear-buffer-mask color-buffer depth-buffer)) diff --git a/2d/window.scm b/2d/window.scm index 416a8cf..7697e07 100644 --- a/2d/window.scm +++ b/2d/window.scm @@ -75,19 +75,14 @@ (let ((flags (if (window-fullscreen? window) '(opengl fullscreen) 'opengl)) (width (vx (window-resolution window))) (height (vy (window-resolution window)))) + (signal-set! window-width width) + (signal-set! window-height height) ;; Initialize everything (SDL:enable-unicode #t) (SDL:init 'everything) ;; Open SDL window in OpenGL mode. (SDL:set-video-mode width height 24 flags) (SDL:set-caption (window-title window)) - ;; 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)) |