summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2015-04-05 21:09:45 -0400
committerDavid Thompson <dthompson2@worcester.edu>2015-04-05 21:09:45 -0400
commit3f8a886eee2de1cc40c36c360c89b0907992e751 (patch)
treee722e4edb1218ed433b9431e1771e3fa754b45f4
parent076a01c36d01c71ffcce1737855b2928bc6165bc (diff)
render: model: Add null-model.
* sly/render/model.scm (null-model): New variable. (model-null?): New procedure. (draw-model): Test for null models.
-rw-r--r--sly/render/model.scm17
1 files changed, 15 insertions, 2 deletions
diff --git a/sly/render/model.scm b/sly/render/model.scm
index 2686d8c..8f83ed5 100644
--- a/sly/render/model.scm
+++ b/sly/render/model.scm
@@ -38,8 +38,11 @@
#:use-module (sly render color)
#:use-module (sly render context)
#:use-module (sly render mesh)
- #:export (make-model model model-inherit
- model?
+ #:export (make-model
+ model
+ model-inherit
+ model? model-null?
+ null-model
model-mesh model-transform model-texture model-shader model-color
model-blend-mode model-depth-test? model-children
draw-model
@@ -101,6 +104,14 @@ changing the fields specified in KWARGS."
(struct-ref original index))))
fields field-indices))))))
+(define null-model
+ (make-model #:shader null-shader-program))
+
+(define (model-null? model)
+ "Return #t if MODEL has no mesh and no children."
+ (and (eq? (model-mesh model) null-mesh)
+ (null? (model-children model))))
+
(define (set-transform-identity! t)
(let ((matrix (transform-matrix t)))
(array-set! matrix 1 0 0)
@@ -128,6 +139,8 @@ shader, vertex array, uniforms, blend mode, etc. to the render
CONTEXT."
(define (iter model view context)
(match model
+ ((? model-null? _)
+ *unspecified*)
(($ <model> mesh local-transform texture shader color blend-mode
depth-test? children)
(with-transform-excursion context