summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2018-10-25 08:46:53 -0400
committerDavid Thompson <dthompson2@worcester.edu>2018-10-25 08:46:53 -0400
commitb06604c6ec1bee068169f632441c93a31f917702 (patch)
treef299d4bd04babbd94429464821a3c311b6c69c27
parenta8a9c3962e78e01ca04e8f67115c15ea0a74592f (diff)
render: Add gpu-apply/instanced syntax.
* chickadee/render.scm (gpu-apply/instanced*, gpu-apply/instanced): New syntax.
-rw-r--r--chickadee/render.scm22
1 files changed, 19 insertions, 3 deletions
diff --git a/chickadee/render.scm b/chickadee/render.scm
index cdf0315..140ec66 100644
--- a/chickadee/render.scm
+++ b/chickadee/render.scm
@@ -43,7 +43,9 @@
with-texture
with-projection
gpu-apply
- gpu-apply*))
+ gpu-apply*
+ gpu-apply/instanced*
+ gpu-apply/instanced))
(define *current-viewport* null-viewport)
(define *current-framebuffer* null-framebuffer)
@@ -152,7 +154,7 @@
(set-uniform-value! (shader-uniform shader sname) value)
(uniform-apply shader rest)))))))
-(define-syntax-rule (gpu-apply* shader vertex-array count . uniforms)
+(define-syntax-rule (gpu-prepare shader vertex-array uniforms)
(begin
;; It's important that the framebuffer is set before setting the
;; viewport because applying a new viewport will clear the current
@@ -170,8 +172,22 @@
(hash-for-each (lambda (name uniform)
(when (eq? 'sampler-2d (uniform-type uniform))
(set-uniform-value! uniform (uniform-value uniform))))
- (shader-uniforms shader))
+ (shader-uniforms shader))))
+
+(define-syntax-rule (gpu-apply* shader vertex-array count . uniforms)
+ (begin
+ (gpu-prepare shader vertex-array uniforms)
(render-vertices vertex-array count)))
(define-syntax-rule (gpu-apply shader vertex-array uniforms ...)
(gpu-apply* shader vertex-array #f uniforms ...))
+
+(define-syntax-rule (gpu-apply/instanced* shader vertex-array count instances .
+ uniforms)
+ (begin
+ (gpu-prepare shader vertex-array uniforms)
+ (render-vertices/instanced vertex-array instances count)))
+
+(define-syntax-rule (gpu-apply/instanced shader vertex-array instances
+ uniforms ...)
+ (gpu-apply/instanced* shader vertex-array #f instances uniforms ...))