summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2018-09-06 09:34:46 -0400
committerDavid Thompson <dthompson2@worcester.edu>2018-09-06 09:34:46 -0400
commit749adfc4101d11784bf8207c2f6cbe6b8638dd13 (patch)
treec7e003957331c9c84d53b97e1b23a1f36fa5c0ed
parentb3f98892edacce79525523984cb72eba2473f9e6 (diff)
render: buffer: Fix pointer argument to glVertexAttribPointer.
This one was a doozy. Took me days to figure out why something wasn't rendering properly and this was the culprit! The last argument, the "pointer" argument, to glVertexAttribPointer is supposed to point to the byte offset to start reading data from the VBO. I thought this meant that I could pass a pointer to an integer that contained the offset. WRONG! The pointer value itself must encode that offset. You can see in the diff that I knew this code didn't work when the offset was 0, but somehow a null pointer worked and I just made that case work while leaving every other offset broken. The more I know! * chickadee/render/buffer.scm (apply-typed-buffer): Pass a pointer whose address is the byte offset of the buffer, rather than a pointer whose dereferenced value is an integer representing the byte offset.
-rw-r--r--chickadee/render/buffer.scm5
1 files changed, 1 insertions, 4 deletions
diff --git a/chickadee/render/buffer.scm b/chickadee/render/buffer.scm
index 48362f0..686197c 100644
--- a/chickadee/render/buffer.scm
+++ b/chickadee/render/buffer.scm
@@ -353,10 +353,7 @@ be specified for the buffer."
(typed-buffer-type-gl typed-buffer)
(typed-buffer-normalized? typed-buffer)
(typed-buffer-stride typed-buffer)
- (let ((offset (typed-buffer-offset typed-buffer)))
- (if (zero? offset)
- %null-pointer
- (bytevector->pointer (s32vector offset)))))))
+ (make-pointer (typed-buffer-offset typed-buffer)))))
;; TODO: Handle 4-byte alignment rule for the types that need it.
(define (typed-buffer->vector typed-buffer)