From 7f3b8919aa22d8fe01db4f57f679b8bfb75ab16e Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Mon, 2 Jul 2012 18:18:42 +0200 Subject: [PATCH] More meshes --- src/gacela.scm | 28 ++++++---------------------- src/views.scm | 8 +++++--- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/gacela.scm b/src/gacela.scm index 8fa9f52..06986b8 100644 --- a/src/gacela.scm +++ b/src/gacela.scm @@ -18,7 +18,6 @@ (define-module (gacela gacela) #:use-module (gacela events) #:use-module (gacela video) - #:use-module ((gacela video) #:renamer (symbol-prefix-proc 'video:)) #:use-module (gacela audio) #:use-module (ice-9 optargs) #:export (*title* @@ -119,7 +118,7 @@ (to-origin) (refresh-active-mobs) (run-mobs) - (draw-views) + (draw-meshes) (flip-screen) (delay-frame)))) (quit-video)) @@ -341,29 +340,14 @@ ;;; Views Factory -(define active-views (make-hash-table)) +(define default-view (make-hash-table)) -(define* (draw-views #:optional (views (hash-map->list (lambda (k v) v) active-views))) - (cond ((not (null? views)) +(define* (draw-meshes #:optional (meshes (hash-map->list (lambda (k v) v) default-view))) + (cond ((not (null? meshes)) (catch #t - (lambda* () ((car views))) + (lambda () (glmatrix-block ((car meshes)))) (lambda (key . args) #f)) - (draw-views (cdr views))))) - -;; (define-macro (define-view name content) -;; `(begin -;; (hash-set! active-views ',name (lambda () (glmatrix-block ,content))) -;; ',name)) - - -;;; Views Primitives - -;(define-macro (translate x y view-or-z . view) -; (let* ((z (if (null? view) 0 view-or-z)) -; (view (if (null? view) view-or-z (car view)))) -; `(begin -; (gltranslate ,x ,y ,z) -; ,view))) + (draw-meshes (cdr meshes))))) (module-map (lambda (sym var) diff --git a/src/views.scm b/src/views.scm index 5fcf854..b772562 100644 --- a/src/views.scm +++ b/src/views.scm @@ -26,15 +26,17 @@ (hash-set! active-views ',name (lambda () (video:glmatrix-block ,content))) ',name)) -(define-macro (lambda-mesh . content) - `(lambda () ,content)) +(define-macro (mesh . content) + `(let ((x 0) (y 0) (z 0) + (angle 0)) + (lambda () ,content))) (define-macro (define-basic-meshes . symbols) (cond ((null? symbols) `#t) (else `(begin - (define (,(caar symbols) . params) (lambda-visible (video:glmatrix-block (apply ,(cadar symbols) params)))) + (define (,(caar symbols) . params) (mesh (apply ,(cadar symbols) params))) (define-basic-meshes ,@(cdr symbols)))))) (define-basic-meshes -- 2.39.5