lovr.graphics.newBuffer

Creates a Buffer.


buffer = lovr.graphics.newBuffer(length, type)

Arguments

NameTypeDescription
lengthnumber The length of the Buffer.
typeFieldType The type of each item in the Buffer.

Returns

NameTypeDescription
bufferBuffer The new Buffer.

buffer = lovr.graphics.newBuffer(data, type)

Arguments

NameTypeDescription
datatable The initial data to put into the Buffer. The length of the Buffer will be determined by the contents of the table. The contents can be a mix of tables, numbers, and vectors, but the length calculation requires each field to consistently use one type of data.
typeFieldType The type of each item in the Buffer.

Returns

NameTypeDescription
bufferBuffer The new Buffer.

buffer = lovr.graphics.newBuffer(length, format)

Arguments

NameTypeDefaultDescription
lengthnumber The length of the Buffer.
formattablenil A list of fields in the Buffer (see notes). nil is a valid format, but means only Blobs can be written to the Buffer from Lua.
.layoutBufferLayoutpacked How to lay out the Buffer fields in memory.
.stridenumber The stride of the Buffer, in bytes. When nil, the stride will be automatically computed based on the fields. The stride can not be zero or smaller than the max byte occupied by one of the fields. The layout of the Buffer may adjust the stride.

Returns

NameTypeDescription
bufferBuffer The new Buffer.

buffer = lovr.graphics.newBuffer(data, format)

Arguments

NameTypeDefaultDescription
datatable The initial data to put into the Buffer. The length of the Buffer will be determined by the contents of the table. The contents can be a mix of tables, numbers, and vectors, but the length calculation requires each field to consistently use one type of data.
formattablenil A list of fields in the Buffer (see notes). nil is a valid format, but means only Blobs can be written to the Buffer from Lua.
.layoutBufferLayoutpacked How to lay out the Buffer fields in memory.
.stridenumber The stride of the Buffer, in bytes. When nil, the stride will be automatically computed based on the fields. The stride can not be zero or smaller than the max byte occupied by one of the fields. The layout of the Buffer may adjust the stride.

Returns

NameTypeDescription
bufferBuffer The new Buffer.

buffer = lovr.graphics.newBuffer(blob, type)

Arguments

NameTypeDescription
blobBlob A Blob with the initial contents of the Buffer. The size of the Blob will be used to determine the length of the Buffer.
typeFieldType The type of each item in the Buffer.

Returns

NameTypeDescription
bufferBuffer The new Buffer.

buffer = lovr.graphics.newBuffer(blob, format)

Arguments

NameTypeDefaultDescription
blobBlob A Blob with the initial contents of the Buffer. The size of the Blob will be used to determine the length of the Buffer.
formattablenil A list of fields in the Buffer (see notes). nil is a valid format, but means only Blobs can be written to the Buffer from Lua.
.layoutBufferLayoutpacked How to lay out the Buffer fields in memory.
.stridenumber The stride of the Buffer, in bytes. When nil, the stride will be automatically computed based on the fields. The stride can not be zero or smaller than the max byte occupied by one of the fields. The layout of the Buffer may adjust the stride.

Returns

NameTypeDescription
bufferBuffer The new Buffer.

Notes

The format table can contain a list of FieldTypes or a list of tables to provide extra information about each field. Each inner table has the following keys:

If no table or Blob is used to define the initial Buffer contents, its data will be undefined.

There is currently a max of 16 fields.

See also