summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am1
-rw-r--r--starling/kernel.scm8
-rw-r--r--starling/node-2d.scm5
-rw-r--r--starling/system.scm15
4 files changed, 21 insertions, 8 deletions
diff --git a/Makefile.am b/Makefile.am
index bc2ff0d..503a280 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -40,6 +40,7 @@ godir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/site-ccache
SOURCES = \
starling/config.scm \
starling/inotify.scm \
+ starling/system.scm \
starling/asset.scm \
starling/node.scm \
starling/scene.scm \
diff --git a/starling/kernel.scm b/starling/kernel.scm
index c50cd98..25b6917 100644
--- a/starling/kernel.scm
+++ b/starling/kernel.scm
@@ -41,6 +41,7 @@
#:use-module (starling node)
#:use-module (starling repl)
#:use-module (starling scene)
+ #:use-module (starling system)
#:use-module ((sdl2 video) #:prefix sdl2:)
#:use-module (system repl command)
#:export (<window-config>
@@ -57,7 +58,6 @@
avg-frame-time
current-kernel
boot-kernel
- elapsed-time
fps
reboot-current-scene)
#:re-export (abort-game))
@@ -248,9 +248,6 @@
(define-method (on-scenes-empty (kernel <kernel>))
(abort-game))
-(define (elapsed-time)
- (sdl-ticks))
-
(define-method (fps kernel)
(/ 1000.0 (avg-frame-time kernel)))
@@ -285,7 +282,8 @@
(const #t)
(lambda ()
(parameterize ((current-kernel kernel)
- (current-gpu (make-gpu (gl-context kernel))))
+ (current-gpu (make-gpu (gl-context kernel)))
+ (current-window (window kernel)))
(activate kernel)
(push-scene kernel (thunk))
(run-game* #:update (lambda (dt) (update-tree kernel dt))
diff --git a/starling/node-2d.scm b/starling/node-2d.scm
index 709eeec..947e377 100644
--- a/starling/node-2d.scm
+++ b/starling/node-2d.scm
@@ -39,11 +39,10 @@
#: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)
#:use-module (starling scene)
+ #:use-module (starling system)
#:export (<camera-2d>
target
offset
@@ -232,7 +231,7 @@
;; more views.
(define (make-default-views)
- (match (window-size (window (current-kernel)))
+ (match (current-window-size)
((width height)
(list
(make <view-2d>
diff --git a/starling/system.scm b/starling/system.scm
new file mode 100644
index 0000000..f498aa4
--- /dev/null
+++ b/starling/system.scm
@@ -0,0 +1,15 @@
+(define-module (starling system)
+ #:use-module (oop goops)
+ #:use-module (sdl2)
+ #:use-module (sdl2 video)
+ #:export (elapsed-time
+ current-window
+ current-window-size))
+
+(define (elapsed-time)
+ (sdl-ticks))
+
+(define current-window (make-parameter #f))
+
+(define (current-window-size)
+ (window-size (current-window)))