From 762057a93447ad15e64008e3a820b32772a71c4b Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 12 Oct 2020 19:45:04 -0400 Subject: graphics: buffer: Always apply index buffer before rendering. I can't believe this didn't cause me trouble before now. Wow. --- chickadee/graphics/buffer.scm | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'chickadee') 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)))) -- cgit v1.2.3