summaryrefslogtreecommitdiff
path: root/chickadee/graphics/buffer.scm
diff options
context:
space:
mode:
Diffstat (limited to 'chickadee/graphics/buffer.scm')
-rw-r--r--chickadee/graphics/buffer.scm35
1 files changed, 20 insertions, 15 deletions
diff --git a/chickadee/graphics/buffer.scm b/chickadee/graphics/buffer.scm
index cfb541f..9e5a791 100644
--- a/chickadee/graphics/buffer.scm
+++ b/chickadee/graphics/buffer.scm
@@ -571,7 +571,7 @@ argument may be overridden. The following values are supported:
((index . buffer-view)
(apply-buffer-view buffer-view index)))
attributes)
- (apply-buffer-view indices)
+ (when indices (apply-buffer-view indices))
(set-gpu-vertex-array! (current-gpu) null-vertex-array)
array))
@@ -585,21 +585,26 @@ argument may be overridden. The following values are supported:
('triangle-strip (begin-mode triangle-strip))
('triangle-fan (begin-mode triangle-fan))))
-(define* (render-vertices array #:optional count)
+(define* (render-vertices array #:key count (offset 0))
(set-gpu-vertex-array! (current-gpu) array)
(let ((indices (vertex-array-indices array)))
- (gl-draw-elements (vertex-array-mode-gl array)
- (or count
- (buffer-view-length indices))
- (buffer-view-type-gl indices)
- %null-pointer)))
-
-(define* (render-vertices/instanced array instances #:optional count)
+ (if 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)))
- (gl-draw-elements-instanced (vertex-array-mode-gl array)
- (or count
- (buffer-view-length indices))
- (buffer-view-type-gl indices)
- %null-pointer
- instances)))
+ (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)
+ (gl-draw-arrays-instanced (vertex-array-mode-gl array)
+ offset count instances))))