Buffer:getFormat

Edit

Returns the format the Buffer was created with.

format = Buffer:getFormat()

Arguments

None

Returns

NameTypeDescription
formattable A list of fields comprising the format.
.[].namestring The name of the field (if fields were created with names).
.[].type* The DataType of the field, or a recursive table with the sub-format.
.[].offsetnumber The offset of the field relative to its parent, in bytes.
.[].lengthnumber The array length of the field, or nil if it's not an array.
.[].stridenumber The stride of the field in bytes, or nil if it's not an array.

Example

function lovr.load()
  buffer = lovr.graphics.newBuffer({
    { 'a', 'float' },
    { 'b', 'un16x2' }
  })

  for i, field in ipairs(buffer:getFormat()) do
    print(('%s: %s'):format(field.name, field.type))
  end

  -- prints the following:
  -- a: f32
  -- b: un16x2
end

See also