summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 ...))