]> git.jsancho.org Git - gacela.git/blob - src/views.scm
b77256280c9e264b65930a6bce685232aad6c30e
[gacela.git] / src / views.scm
1 ;;; Gacela, a GNU Guile extension for fast games development
2 ;;; Copyright (C) 2009 by Javier Sancho Fernandez <jsf at jsancho dot org>
3 ;;;
4 ;;; This program is free software: you can redistribute it and/or modify
5 ;;; it under the terms of the GNU General Public License as published by
6 ;;; the Free Software Foundation, either version 3 of the License, or
7 ;;; (at your option) any later version.
8 ;;;
9 ;;; This program is distributed in the hope that it will be useful,
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ;;; GNU General Public License for more details.
13 ;;;
14 ;;; You should have received a copy of the GNU General Public License
15 ;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17
18 (define-module (gacela views)
19   #:use-module (gacela gacela)
20   #:use-module ((gacela video) #:renamer (symbol-prefix-proc 'video:))
21   #:use-module ((gacela gl) #:select (glPushMatrix glPopMatrix))
22   #:use-module (ice-9 optargs))
23
24 (define-macro (define-view name content)
25   `(begin
26      (hash-set! active-views ',name (lambda () (video:glmatrix-block ,content)))
27      ',name))
28
29 (define-macro (mesh . content)
30   `(let ((x 0) (y 0) (z 0)
31         (angle 0))
32      (lambda () ,content)))
33
34 (define-macro (define-basic-meshes . symbols)
35   (cond ((null? symbols)
36          `#t)
37         (else
38          `(begin
39             (define (,(caar symbols) . params) (mesh (apply ,(cadar symbols) params)))
40             (define-basic-meshes ,@(cdr symbols))))))
41
42 (define-basic-meshes
43   (rectangle video:draw-rectangle)
44   (square video:draw-square))
45
46 (module-map (lambda (sym var)
47               (if (not (eq? sym '%module-public-interface))
48                   (module-export! (current-module) (list sym))))
49             (current-module))