diff options
Diffstat (limited to 'catbird/camera.scm')
-rw-r--r-- | catbird/camera.scm | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/catbird/camera.scm b/catbird/camera.scm index a3d8fd3..e4463be 100644 --- a/catbird/camera.scm +++ b/catbird/camera.scm @@ -45,8 +45,8 @@ #:re-export (width height)) (define-root-class <camera> () - (width #:accessor width #:init-keyword #:width) - (height #:accessor height #:init-keyword #:height) + (width #:accessor width #:init-keyword #:width #:init-value 0.0) + (height #:accessor height #:init-keyword #:height #:init-value 0.0) (projection-matrix #:getter projection-matrix #:init-thunk make-identity-matrix4) (view-matrix #:getter view-matrix #:init-thunk make-identity-matrix4)) @@ -58,6 +58,11 @@ (refresh-projection camera) (refresh-view camera)) +(define-method (resize (camera <camera>) w h) + (set! (width camera) w) + (set! (height camera) h) + (refresh-projection camera)) + (define current-camera (make-parameter #f)) @@ -70,6 +75,13 @@ (define-method (initialize (camera <camera-2d>) initargs) (next-method) + (refresh-bounding-box-size camera)) + +(define-method (resize (camera <camera-2d>) w h) + (next-method) + (refresh-bounding-box-size camera)) + +(define-method (refresh-bounding-box-size (camera <camera-2d>)) (let ((bb (view-bounding-box camera))) (set-rect-width! bb (width camera)) (set-rect-height! bb (height camera)))) |