summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--starling/node-2d.scm15
1 files changed, 14 insertions, 1 deletions
diff --git a/starling/node-2d.scm b/starling/node-2d.scm
index c0cb243..a0b2746 100644
--- a/starling/node-2d.scm
+++ b/starling/node-2d.scm
@@ -33,7 +33,9 @@
#:use-module (chickadee render texture)
#:use-module (chickadee render viewport)
#:use-module (chickadee scripting)
+ #:use-module (ice-9 match)
#:use-module (oop goops)
+ #:use-module (sdl2 video)
#:use-module (starling asset)
#:use-module (starling kernel)
#:use-module (starling node)
@@ -175,8 +177,19 @@
;; The canvas is the root of a 2D scene. It handles rendering one or
;; more views.
+(define (make-default-views)
+ (match (window-size (window (current-kernel)))
+ ((width height)
+ (list
+ (make <view-2d>
+ #:camera (make <camera-2d>
+ #:width width
+ #:height height)
+ #:area (make-rect 0 0 width height))))))
+
(define-class <canvas> (<node>)
- (views #:accessor views #:init-form '() #:init-keyword #:views))
+ (views #:accessor views #:init-thunk make-default-views
+ #:init-keyword #:views))
(define-method (update (canvas <canvas>) dt)
(for-each (lambda (view)