Version: beta
FUNCTION | |
---|---|
buffer.create() | creates a new buffer |
buffer.get_stream() | gets a stream from a buffer |
buffer.copy_stream() | copies data from one stream to another |
buffer.copy_buffer() | copies one buffer to another |
buffer.get_bytes() | gets data from a stream |
CONSTANT | |
---|---|
buffer.VALUE_TYPE_UINT8 | uint8 |
buffer.VALUE_TYPE_UINT16 | uint16 |
buffer.VALUE_TYPE_UINT32 | uint32 |
buffer.VALUE_TYPE_UINT64 | uint64 |
buffer.VALUE_TYPE_INT8 | int8 |
buffer.VALUE_TYPE_INT16 | int16 |
buffer.VALUE_TYPE_INT32 | int32 |
buffer.VALUE_TYPE_INT64 | int64 |
buffer.VALUE_TYPE_FLOAT32 | float32 |
buffer.create(element_count,declaration)
PARAMETERS
element_count |
The number of elements the buffer should hold |
declaration |
A table where each entry (table) describes a stream
|
RETURNS
buffer |
the new buffer |
EXAMPLES
How to create and initialize a bufferfunction init(self) local size = 128 self.image = buffer.create( size * size, { {name=hash("rgb"), type=buffer.VALUE_TYPE_UINT8, count=3 } }) self.imagestream = buffer.get_stream(self.image, hash("rgb")) for y=0,self.height-1 do for x=0,self.width-1 do local index = y * self.width * 3 + x * 3 + 1 self.imagestream[index + 0] = self.r self.imagestream[index + 1] = self.g self.imagestream[index + 2] = self.b end end
buffer.get_stream(buffer,stream_name)
PARAMETERS
buffer |
the buffer to get the stream from |
stream_name |
the stream name |
RETURNS
stream |
the data stream |
buffer.copy_stream(dst,dstoffset,src,srcoffset,count)
PARAMETERS
dst |
the destination stream |
dstoffset |
the offset to start copying data to (measured in value type) |
src |
the source data stream |
srcoffset |
the offset to start copying data from (measured in value type) |
count |
the number of values to copy (measured in value type) |
EXAMPLES
How to update a texture of a sprite:-- copy entire stream local srcstream = buffer.get_stream(srcbuffer, hash("xyz")) local dststream = buffer.get_stream(dstbuffer, hash("xyz")) buffer.copy_stream(dststream, 0, srcstream, 0, #srcstream)
buffer.copy_buffer(dst,dstoffset,src,srcoffset,count)
PARAMETERS
dst |
the destination buffer |
dstoffset |
the offset to start copying data to |
src |
the source data buffer |
srcoffset |
the offset to start copying data from |
count |
the number of elements to copy |
EXAMPLES
How to copy elements (e.g. vertices) from one buffer to another-- copy entire buffer buffer.copy_buffer(dstbuffer, 0, srcbuffer, 0, #srcbuffer) -- copy last 10 elements to the front of another buffer buffer.copy_buffer(dstbuffer, 0, srcbuffer, #srcbuffer - 10, 10)
buffer.get_bytes(buffer,stream_name)
PARAMETERS
buffer |
the source buffer |
stream_name |
the name of the stream |
RETURNS
data |
the buffer data as a Lua string |
uint8
Unsigned integer, 1 byte
uint16
Unsigned integer, 2 bytes
uint32
Unsigned integer, 4 bytes
uint64
Unsigned integer, 8 bytes
int8
Signed integer, 1 byte
int16
Signed integer, 2 bytes
int32
Signed integer, 4 bytes
int64
Signed integer, 8 bytes
float32
Float, single precision, 4 bytes