render: buffer: Add render-vertices/instanced procedure.
authorDavid Thompson <dthompson2@worcester.edu>
Thu, 25 Oct 2018 12:46:25 +0000 (08:46 -0400)
committerDavid Thompson <dthompson2@worcester.edu>
Thu, 25 Oct 2018 12:46:25 +0000 (08:46 -0400)
* chickadee/render/buffer.scm (render-vertices/instanced): New procedure.

chickadee/render/buffer.scm

index 83a2925..5d13c2e 100644 (file)
@@ -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)))