summaryrefslogtreecommitdiff
path: root/2d
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-01-26 16:21:48 -0500
committerDavid Thompson <dthompson2@worcester.edu>2014-01-26 16:21:48 -0500
commitc9c97dd8bcb0b6365b7180d5e5c946eb179c057e (patch)
tree2ea441e74e7615bf5314c010f9a3e5f5e5303ecc /2d
parent446750df6a786a8fcce7309e2f9b145e53e24e4f (diff)
Move OpenGL viewport settings to game module.
* 2d/window.scm (open-window): Remove viewport config. * 2d/game.scm (draw): Add viewport config.
Diffstat (limited to '2d')
-rw-r--r--2d/game.scm7
-rw-r--r--2d/window.scm9
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))