From c9c97dd8bcb0b6365b7180d5e5c946eb179c057e Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 26 Jan 2014 16:21:48 -0500 Subject: Move OpenGL viewport settings to game module. * 2d/window.scm (open-window): Remove viewport config. * 2d/game.scm (draw): Add viewport config. --- 2d/game.scm | 7 +++++++ 2d/window.scm | 9 ++------- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to '2d') 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)) -- cgit v1.2.3