summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-09-01 19:32:23 -0400
committerDavid Thompson <dthompson2@worcester.edu>2014-09-01 19:32:23 -0400
commit11b940e20bcdc162ddf9d2b3fe51dbb7aba2a2be (patch)
treee2d6014804be3b64cf77c55250c31fb2a2d388a4
parent69785bcd852d6344d19e755b7ea9cb38752b8156 (diff)
camera: Add orthographic-camera procedure.
* sly/camera (orthographic-camera): New procedure.
-rw-r--r--sly/camera.scm20
1 files changed, 20 insertions, 0 deletions
diff --git a/sly/camera.scm b/sly/camera.scm
index 1967b80..2b4d77f 100644
--- a/sly/camera.scm
+++ b/sly/camera.scm
@@ -31,6 +31,7 @@
#:use-module (sly signal)
#:use-module (sly transform)
#:export (make-camera
+ orthographic-camera
camera?
camera-scene
camera-location
@@ -56,6 +57,25 @@
(clear-color black))
(%make-camera scene location projection viewport clear-flags clear-color))
+(define* (orthographic-camera scene width height
+ #:optional #:key
+ (z-near 0) (z-far 1)
+ (viewport (make-rect 0 0 width height))
+ (clear-flags '(color-buffer depth-buffer))
+ (clear-color black))
+ "Return a camera that renders SCENE using an orthographic (2D)
+projection of size WIDTH x HEIGHT. Optionally, z-axis clipping planes
+Z-NEAR and Z-FAR can be specified, but default to 0 and 1,
+respectively. By default, the camera's VIEWPORT uses the same
+dimensions as the projection, which is convenient if the dimensions
+are in pixels. Like 'make-camera', custom CLEAR-COLOR and CLEAR-FLAGS
+can be specified."
+ (make-camera scene identity-transform
+ (orthographic-projection 0 width 0 height z-near z-far)
+ viewport
+ #:clear-flags clear-flags
+ #:clear-color clear-color))
+
;; guile-opengl's clear-buffer-mask does not work with symbols, only
;; syntax.
(define (clear-buffer-mask . flags)