diff options
author | David Thompson <dthompson2@worcester.edu> | 2021-05-10 17:12:11 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2021-05-10 17:12:11 -0400 |
commit | 3bbb377e2ceecea3c1ed7abdad7db6f506f70f20 (patch) | |
tree | 47376b0650787e999665b4190ce362d862ecc6e9 | |
parent | e97971c3a11dfb43dab029863e70117f413066a7 (diff) |
graphics: buffer: Fix indexed rendering with a byte offset.
Need to pass in the byte offset as a pointer to gl-draw-elements
rather than using the null pointer aka an offset of 0 bytes.
-rw-r--r-- | chickadee/graphics/buffer.scm | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/chickadee/graphics/buffer.scm b/chickadee/graphics/buffer.scm index 52c1293..89ee376 100644 --- a/chickadee/graphics/buffer.scm +++ b/chickadee/graphics/buffer.scm @@ -380,12 +380,13 @@ resized." ('double 8))) (define-record-type <buffer-view> - (%make-buffer-view name buffer offset component-type + (%make-buffer-view name buffer offset offset-pointer component-type normalized? length type max min sparse divisor) buffer-view? (name buffer-view-name) (buffer buffer-view->buffer) (offset buffer-view-offset) + (offset-pointer buffer-view-offset-pointer) (component-type buffer-view-component-type) (normalized? buffer-view-normalized?) (length buffer-view-length) @@ -453,8 +454,9 @@ divisor of 0 means that a single element is used for every instance and is used for the data being instanced. A divisor of 1 means that each element is used for 1 instance. A divisor of 2 means that each element is used for 2 instances, and so on." - (%make-buffer-view name buffer offset component-type - normalized? length type max min sparse divisor)) + (let ((offset-ptr (make-pointer offset))) + (%make-buffer-view name buffer offset offset-ptr component-type + normalized? length type max min sparse divisor))) (define (display-buffer-view buffer-view port) (format port "#<buffer-view name: ~s buffer: ~a type: ~s component-type: ~s length: ~d offset: ~d divisor: ~d>" @@ -496,7 +498,7 @@ element is used for 2 instances, and so on." (buffer-view-type-gl buffer-view) (buffer-view-normalized? buffer-view) (buffer-view-stride buffer-view) - (make-pointer (buffer-view-offset buffer-view))) + (buffer-view-offset-pointer buffer-view)) (let ((divisor (buffer-view-divisor buffer-view))) (when divisor (gl-vertex-attrib-divisor attribute-index divisor)))))) @@ -600,7 +602,7 @@ argument may be overridden. The following values are supported: (or count (buffer-view-length indices)) (buffer-view-type-gl indices) - %null-pointer)) + (buffer-view-offset-pointer indices))) (gl-draw-arrays (vertex-array-mode-gl array) offset (or count @@ -618,7 +620,7 @@ argument may be overridden. The following values are supported: (or count (buffer-view-length indices)) (buffer-view-type-gl indices) - %null-pointer + (buffer-view-offset-pointer indices) instances)) (gl-draw-arrays-instanced (vertex-array-mode-gl array) offset count instances))))) |