summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/render/buffer.scm7
1 files changed, 5 insertions, 2 deletions
diff --git a/chickadee/render/buffer.scm b/chickadee/render/buffer.scm
index 4d196d9..e784456 100644
--- a/chickadee/render/buffer.scm
+++ b/chickadee/render/buffer.scm
@@ -202,7 +202,7 @@ for streaming data to the GPU every frame."
"Return #t if buffer data has been mapped from GPU."
(if (buffer-data buffer) #t #f))
-(define (map-buffer! buffer)
+(define* (map-buffer! buffer #:optional (mode 'read-write))
"Map the memory space for BUFFER from the GPU to the CPU, allowing
the vertex buffer to be updated with new vertex data. The
'unmap-buffer!' procedure must be called to submit the new
@@ -215,7 +215,10 @@ vertex buffer data back to the GPU."
;; Orphan the buffer to avoid implicit synchronization.
;; See: https://www.opengl.org/wiki/Buffer_Object_Streaming#Buffer_re-specification
(gl-buffer-data target length %null-pointer (buffer-usage-gl buffer)))
- (let ((ptr (gl-map-buffer target (version-1-5 read-write))))
+ (let ((ptr (gl-map-buffer target (match mode
+ ('read-write (version-1-5 read-write))
+ ('read-only (version-1-5 read-only))
+ ('write-only (version-1-5 write-only))))))
(set-buffer-data! buffer (pointer->bytevector ptr length))))))
(define (unmap-buffer! buffer)