summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/render.scm10
-rw-r--r--chickadee/render/framebuffer.scm22
2 files changed, 20 insertions, 12 deletions
diff --git a/chickadee/render.scm b/chickadee/render.scm
index 140ec66..5b95d1b 100644
--- a/chickadee/render.scm
+++ b/chickadee/render.scm
@@ -84,11 +84,13 @@
(define-syntax-rule (with-framebuffer framebuffer body ...)
(with (*current-framebuffer* framebuffer)
- ;; As a convenience, initialize the viewport as well so that
- ;; the user doesn't have to explicitly make a viewport unless
- ;; they actually want to do fancy viewport manipulations.
+ ;; As a convenience, initialize the viewport and projection
+ ;; matrix as well so that the user doesn't have to explicitly
+ ;; make a viewport and/or projection matrix unless they
+ ;; actually want to do fancy viewport manipulations.
(with-viewport (framebuffer-viewport framebuffer)
- body ...)))
+ (with-projection (framebuffer-projection framebuffer)
+ body ...))))
(define-syntax-rule (with-blend-mode blend-mode body ...)
(with (*current-blend-mode* blend-mode) body ...))
diff --git a/chickadee/render/framebuffer.scm b/chickadee/render/framebuffer.scm
index a4c98f7..86fc417 100644
--- a/chickadee/render/framebuffer.scm
+++ b/chickadee/render/framebuffer.scm
@@ -28,6 +28,7 @@
#:use-module (system foreign)
#:use-module (gl)
#:use-module (gl enums)
+ #:use-module (chickadee math matrix)
#:use-module (chickadee render gl)
#:use-module (chickadee render gpu)
#:use-module ((chickadee render texture) #:select (make-texture null-texture))
@@ -36,6 +37,7 @@
framebuffer?
framebuffer-texture
framebuffer-viewport
+ framebuffer-projection
null-framebuffer
apply-framebuffer
*framebuffer-state*))
@@ -53,15 +55,16 @@
(u32vector-ref bv 0)))
(define-record-type <framebuffer>
- (%make-framebuffer id renderbuffer-id texture viewport)
+ (%make-framebuffer id renderbuffer-id texture viewport projection)
framebuffer?
(id framebuffer-id)
(renderbuffer-id framebuffer-renderbuffer-id)
(texture framebuffer-texture)
- (viewport framebuffer-viewport))
+ (viewport framebuffer-viewport)
+ (projection framebuffer-projection))
(define null-framebuffer
- (%make-framebuffer 0 0 null-texture null-viewport))
+ (%make-framebuffer 0 0 null-texture null-viewport (make-identity-matrix4)))
(define <<framebuffer>> (class-of null-framebuffer))
@@ -99,15 +102,18 @@ dimensions WIDTH x HEIGHT."
#:mag-filter mag-filter
#:wrap-s wrap-s
#:wrap-t wrap-t))
- ;; It is convenient to make a default viewport for the
- ;; framebuffer so that the rendering engine can set it
- ;; whenever it changes to this framebuffer, saving users
- ;; the trouble of having to this tedious task themselves.
+ ;; It is convenient to make a default viewport and
+ ;; projection matrix for the framebuffer so that the
+ ;; rendering engine can set it whenever it changes to
+ ;; this framebuffer, saving users the trouble of having
+ ;; to this tedious task themselves.
(viewport (make-viewport 0 0 width height))
+ (projection (orthographic-projection 0 width height 0 0 1))
(framebuffer (%make-framebuffer framebuffer-id
renderbuffer-id
texture
- viewport)))
+ viewport
+ projection)))
(gpu-state-set! *framebuffer-state* framebuffer)
;; Setup depth buffer.
(gl-bind-renderbuffer (version-3-0 renderbuffer)