summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2020-10-12 19:45:04 -0400
committerDavid Thompson <dthompson2@worcester.edu>2020-10-13 08:46:47 -0400
commit762057a93447ad15e64008e3a820b32772a71c4b (patch)
treef1559a4dc91bb9479544d697714ff4956f3ebd4f
parent65bf093f21c5129d784ad196a26a2b3868d0eecd (diff)
graphics: buffer: Always apply index buffer before rendering.
I can't believe this didn't cause me trouble before now. Wow.
-rw-r--r--chickadee/graphics/buffer.scm26
1 files changed, 15 insertions, 11 deletions
diff --git a/chickadee/graphics/buffer.scm b/chickadee/graphics/buffer.scm
index 8a30ea3..be78fc2 100644
--- a/chickadee/graphics/buffer.scm
+++ b/chickadee/graphics/buffer.scm
@@ -610,22 +610,26 @@ argument may be overridden. The following values are supported:
(set-gpu-vertex-array! (current-gpu) array)
(let ((indices (vertex-array-indices array)))
(if indices
- (gl-draw-elements (vertex-array-mode-gl array)
- (or count
- (buffer-view-length indices))
- (buffer-view-type-gl indices)
- %null-pointer)
+ (begin
+ (apply-buffer-view indices)
+ (gl-draw-elements (vertex-array-mode-gl array)
+ (or count
+ (buffer-view-length indices))
+ (buffer-view-type-gl indices)
+ %null-pointer))
(gl-draw-arrays (vertex-array-mode-gl array) offset count))))
(define* (render-vertices/instanced array instances #:key count (offset 0))
(set-gpu-vertex-array! (current-gpu) array)
(let ((indices (vertex-array-indices array)))
(when indices
- (gl-draw-elements-instanced (vertex-array-mode-gl array)
- (or count
- (buffer-view-length indices))
- (buffer-view-type-gl indices)
- %null-pointer
- instances)
+ (begin
+ (apply-buffer-view indices)
+ (gl-draw-elements-instanced (vertex-array-mode-gl array)
+ (or count
+ (buffer-view-length indices))
+ (buffer-view-type-gl indices)
+ %null-pointer
+ instances))
(gl-draw-arrays-instanced (vertex-array-mode-gl array)
offset count instances))))