summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2018-10-25 08:46:25 -0400
committerDavid Thompson <dthompson2@worcester.edu>2018-10-25 08:46:25 -0400
commita8a9c3962e78e01ca04e8f67115c15ea0a74592f (patch)
tree41ef6fb7a2d5be0abe87c954f0f3786da4d898eb
parent047a5f585c2fa641e139487f2790b3e09e3d4357 (diff)
render: buffer: Add render-vertices/instanced procedure.
* chickadee/render/buffer.scm (render-vertices/instanced): New procedure.
-rw-r--r--chickadee/render/buffer.scm13
1 files changed, 12 insertions, 1 deletions
diff --git a/chickadee/render/buffer.scm b/chickadee/render/buffer.scm
index 83a2925..5d13c2e 100644
--- a/chickadee/render/buffer.scm
+++ b/chickadee/render/buffer.scm
@@ -77,7 +77,8 @@
vertex-array-mode
null-vertex-array
*vertex-array-state*
- render-vertices))
+ render-vertices
+ render-vertices/instanced))
;;;
;;; Buffers
@@ -529,3 +530,13 @@ which attributes advance when rendering multiple instances."
(typed-buffer-length indices))
(typed-buffer-type-gl indices)
%null-pointer)))
+
+(define* (render-vertices/instanced array instances #:optional count)
+ (gpu-state-set! *vertex-array-state* array)
+ (let ((indices (vertex-array-indices array)))
+ (gl-draw-elements-instanced (vertex-array-mode-gl array)
+ (or count
+ (typed-buffer-length indices))
+ (typed-buffer-type-gl indices)
+ %null-pointer
+ instances)))