gpu.buffers: grow-buffer helper word
parent
9fccc38994
commit
db5998e121
|
@ -149,6 +149,10 @@ HELP: dynamic-upload
|
||||||
HELP: gpu-data-ptr
|
HELP: gpu-data-ptr
|
||||||
{ $class-description "This class is a union of the " { $link c-ptr } " and " { $link buffer-ptr } " classes. It represents a value that can be supplied either from CPU or GPU memory." } ;
|
{ $class-description "This class is a union of the " { $link c-ptr } " and " { $link buffer-ptr } " classes. It represents a value that can be supplied either from CPU or GPU memory." } ;
|
||||||
|
|
||||||
|
HELP: grow-buffer
|
||||||
|
{ $values { "buffer" buffer } { "target-size" integer } }
|
||||||
|
{ $description "If the " { $link buffer-size } " of the given " { $link buffer } " is less than " { $snippet "target-size" } ", reallocates the buffer to a size large enough to accommodate " { $snippet "target-size" } " bytes. If the buffer is reallocated, the original contents are lost." } ;
|
||||||
|
|
||||||
HELP: index-buffer
|
HELP: index-buffer
|
||||||
{ $class-description "This " { $link buffer-kind } " declares that a " { $link buffer } "'s primary use will be to index vertex arrays." } ;
|
{ $class-description "This " { $link buffer-kind } " declares that a " { $link buffer } "'s primary use will be to index vertex arrays." } ;
|
||||||
|
|
||||||
|
@ -243,6 +247,7 @@ ARTICLE: "gpu.buffers" "Buffer objects"
|
||||||
{ $subsections
|
{ $subsections
|
||||||
allocate-buffer
|
allocate-buffer
|
||||||
allocate-byte-array
|
allocate-byte-array
|
||||||
|
grow-buffer
|
||||||
update-buffer
|
update-buffer
|
||||||
read-buffer
|
read-buffer
|
||||||
copy-buffer
|
copy-buffer
|
||||||
|
|
|
@ -132,6 +132,13 @@ TYPED:: copy-buffer ( to-buffer-ptr: buffer-ptr from-buffer-ptr: buffer-ptr size
|
||||||
from-buffer-ptr offset>> to-buffer-ptr offset>>
|
from-buffer-ptr offset>> to-buffer-ptr offset>>
|
||||||
size glCopyBufferSubData ;
|
size glCopyBufferSubData ;
|
||||||
|
|
||||||
|
: (grow-buffer-size) ( target-size old-size -- new-size )
|
||||||
|
[ 2dup > ] [ 2 * ] while nip ; inline
|
||||||
|
|
||||||
|
TYPED: grow-buffer ( buffer: buffer target-size: integer -- )
|
||||||
|
over buffer-size 2dup >
|
||||||
|
[ (grow-buffer-size) f allocate-buffer ] [ 3drop ] if ; inline
|
||||||
|
|
||||||
:: with-mapped-buffer ( ..a buffer access quot: ( ..a alien -- ..b ) -- ..b )
|
:: with-mapped-buffer ( ..a buffer access quot: ( ..a alien -- ..b ) -- ..b )
|
||||||
buffer bind-buffer :> target
|
buffer bind-buffer :> target
|
||||||
target access gl-access glMapBuffer
|
target access gl-access glMapBuffer
|
||||||
|
|
Loading…
Reference in New Issue