summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/render/buffer.scm17
1 files changed, 14 insertions, 3 deletions
diff --git a/chickadee/render/buffer.scm b/chickadee/render/buffer.scm
index 4363d22..9726698 100644
--- a/chickadee/render/buffer.scm
+++ b/chickadee/render/buffer.scm
@@ -242,14 +242,25 @@ vertex buffer data back to the GPU."
(* (type-size (typed-buffer-type typed-buffer))
(component-type-size (typed-buffer-component-type typed-buffer)))))
+(define (num-elements byte-length byte-offset type component-type)
+ (inexact->exact
+ (floor
+ (/ (- byte-length byte-offset)
+ (* (component-type-size component-type)
+ (type-size type))))))
+
+
(define* (make-typed-buffer #:key
(name "anonymous")
buffer
- (offset 0)
+ type
component-type
normalized?
- (length (buffer-length buffer))
- type
+ (offset 0)
+ (length (num-elements (buffer-length buffer)
+ offset
+ type
+ component-type))
max
min
sparse)