diff options
author | David Thompson <dthompson2@worcester.edu> | 2019-05-10 08:29:28 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2019-05-10 08:29:28 -0400 |
commit | dd1ccc8afc8ec0411ac636f542fd4bb8d4d242af (patch) | |
tree | e2243d4aa06372c196df5a79cd7aaebc9a6485b0 | |
parent | 39d610bb7fd573941c3dd362949a7fff02165908 (diff) |
render: buffer: Allow specifying read/write mode when mapping buffer.
* chickadee/render/buffer.scm (map-buffer!): Add optional 'mode' argument.
-rw-r--r-- | chickadee/render/buffer.scm | 7 |
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) |