summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2017-01-25 22:14:25 -0500
committerDavid Thompson <dthompson2@worcester.edu>2017-01-25 22:14:25 -0500
commitd0305ed735f91995e6f78cb3cfbbb4092da86234 (patch)
tree733e7f2f6d010688d206274d88d4d9aef8b7fc84
parent11406eb75164ea8da06128b6cdb777c2e610cf97 (diff)
render: viewport: Make applying the null viewport a no-op.
* chickadee/render/viewport.scm (apply-viewport): Don't do anything if the viewport being applied is the null viewport.
-rw-r--r--chickadee/render/viewport.scm21
1 files changed, 11 insertions, 10 deletions
diff --git a/chickadee/render/viewport.scm b/chickadee/render/viewport.scm
index 6789766..ad057d1 100644
--- a/chickadee/render/viewport.scm
+++ b/chickadee/render/viewport.scm
@@ -96,16 +96,17 @@ CLEAR-FLAGS are 'color-buffer', 'depth-buffer', 'accum-buffer', and
(define (apply-viewport viewport)
"Set the OpenGL state for VIEWPORT. Clip rendering to the viewport
area, set the clear color, and clear necessary buffers."
- (let ((x (viewport-x viewport))
- (y (viewport-y viewport))
- (w (viewport-width viewport))
- (h (viewport-height viewport))
- (c (viewport-clear-color viewport)))
- (gl-enable (enable-cap scissor-test))
- (gl-viewport x y w h)
- (gl-scissor x y w h)
- (gl-clear-color (color-r c) (color-g c) (color-b c) (color-a c))
- (gl-clear (clear-buffer-mask (viewport-clear-flags viewport)))))
+ (unless (eq? viewport null-viewport)
+ (let ((x (viewport-x viewport))
+ (y (viewport-y viewport))
+ (w (viewport-width viewport))
+ (h (viewport-height viewport))
+ (c (viewport-clear-color viewport)))
+ (gl-enable (enable-cap scissor-test))
+ (gl-viewport x y w h)
+ (gl-scissor x y w h)
+ (gl-clear-color (color-r c) (color-g c) (color-b c) (color-a c))
+ (gl-clear (clear-buffer-mask (viewport-clear-flags viewport))))))
(define *viewport-state*
(make-gpu-state apply-viewport null-viewport))