summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <davet@gnu.org>2015-06-14 20:56:03 -0400
committerDavid Thompson <davet@gnu.org>2015-06-14 20:58:52 -0400
commitc23f81b59db98d7af4fd91a41c9b366823662083 (patch)
tree61e2bdb80e1d8e74419c813c74bef04ae44d36ff
parent0ec98c95075e09567ef05a84dae8f6de40920202 (diff)
Add composite (sly) module.
* sly.scm: New file. * Makefile.am (SOURCES): Add it. * sandbox.in: Use new module. * examples/common.scm: Likewise. * examples/font.scm: Likewise. * README ("Example"): Update example.
-rw-r--r--Makefile.am3
-rw-r--r--README12
-rw-r--r--examples/common.scm11
-rw-r--r--examples/font.scm2
-rw-r--r--sandbox.in25
-rw-r--r--sly.scm60
6 files changed, 72 insertions, 41 deletions
diff --git a/Makefile.am b/Makefile.am
index 621b6af..a6405d5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -57,7 +57,8 @@ SOURCES = \
sly/render/tile-map.scm \
sly/render/context.scm \
sly/render/scene.scm \
- $(WRAPPER_SOURCES)
+ $(WRAPPER_SOURCES) \
+ sly.scm
WRAPPER_SOURCES = \
sly/wrappers/freeimage.scm \
diff --git a/README b/README
index 9a0b681..e2c75c4 100644
--- a/README
+++ b/README
@@ -28,14 +28,10 @@ Sly differentiates itself from most other game engines by encouraging
Here is the simplest Sly application (so far).
#+BEGIN_SRC scheme
- (use-modules (sly game)
- (sly signal)
- (sly window)
- (sly math vector)
- (sly render camera)
- (sly render model)
- (sly render sprite)
- (sly render scene))
+ (use-modules (sly))
+
+ ;; Create OpenGL context and do other setup.
+ (sly-init)
;; The object to render.
(define model
diff --git a/examples/common.scm b/examples/common.scm
index 541488a..65e02df 100644
--- a/examples/common.scm
+++ b/examples/common.scm
@@ -15,15 +15,10 @@
;;; along with this program. If not, see
;;; <http://www.gnu.org/licenses/>.
-(use-modules (sly agenda)
- (sly fps)
- (sly game)
- (sly input keyboard)
- (sly repl)
- (sly signal)
- (sly window))
+(use-modules (sly)
+ (sly fps))
-(open-window)
+(sly-init)
(add-hook! key-press-hook (lambda (key unicode)
(when (eq? key 'escape)
diff --git a/examples/font.scm b/examples/font.scm
index 4ce76e3..4d481d3 100644
--- a/examples/font.scm
+++ b/examples/font.scm
@@ -29,8 +29,6 @@
(load "common.scm")
-(enable-fonts)
-
(define font (load-default-font 18))
(define-signal message-label
diff --git a/sandbox.in b/sandbox.in
index 6929849..f58838b 100644
--- a/sandbox.in
+++ b/sandbox.in
@@ -2,7 +2,7 @@
!#
;;; Sly
-;;; Copyright (C) 2014 David Thompson <dthompson2@worcester.edu>
+;;; Copyright (C) 2015 David Thompson <davet@gnu.org>
;;;
;;; This program is free software: you can redistribute it and/or
;;; modify it under the terms of the GNU General Public License as
@@ -18,28 +18,9 @@
;;; along with this program. If not, see
;;; <http://www.gnu.org/licenses/>.
-;; Include almost every Sly module for convenience.
-(use-modules (sly audio)
- (sly fps)
- (sly game)
- (sly signal)
- (sly window)
- (sly repl)
- (sly utils)
- (sly render color)
- (sly render font)
- (sly render sprite)
- (sly render texture)
- (sly render model)
- (sly render camera)
- (sly render scene)
- (sly input keyboard)
- (sly input mouse)
- (sly math rect)
- (sly math transform)
- (sly math vector))
+(use-modules (sly))
-(open-window)
+(sly-init)
(start-sly-repl)
(add-hook! window-close-hook stop-game-loop)
diff --git a/sly.scm b/sly.scm
new file mode 100644
index 0000000..b92536a
--- /dev/null
+++ b/sly.scm
@@ -0,0 +1,60 @@
+;;; Sly
+;;; Copyright (C) 2015 David Thompson <davet@gnu.org>
+;;;
+;;; This program is free software: you can redistribute it and/or
+;;; modify it under the terms of the GNU General Public License as
+;;; published by the Free Software Foundation, either version 3 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program. If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; Composite module that exports commonly used public modules.
+;;
+;;; Code:
+
+(define-module (sly)
+ #:use-module (sly window)
+ #:use-module (sly render font)
+ #:export (sly-init))
+
+(eval-when (eval load compile)
+ (begin
+ (define %public-modules
+ '((sly agenda)
+ (sly game)
+ (sly signal)
+ (sly window)
+ (sly repl)
+ (sly utils)
+ (sly render color)
+ (sly render font)
+ (sly render sprite)
+ (sly render texture)
+ (sly render model)
+ (sly render camera)
+ (sly render scene)
+ (sly input keyboard)
+ (sly input mouse)
+ (sly math)
+ (sly math rect)
+ (sly math transform)
+ (sly math vector)))
+
+ (for-each (let ((i (module-public-interface (current-module))))
+ (lambda (m)
+ (module-use! i (resolve-interface m))))
+ %public-modules)))
+
+(define* (sly-init #:key (fonts? #t))
+ "Initialize Sly's global state, such as the OpenGL context."
+ (open-window)
+ (when fonts? (enable-fonts)))