DataType

Edit

Different types for Buffer fields. These are scalar, vector, or matrix types, usually packed into small amounts of space to reduce the amount of memory they occupy.

The names are encoded as follows:

ValueDescription
i8x4 Four 8-bit signed integers.
u8x4 Four 8-bit unsigned integers.
sn8x4 Four 8-bit signed normalized values.
un8x4 Four 8-bit unsigned normalized values (aka color).
sn10x3 Three 10-bit signed normalized values, and 2 padding bits.
un10x3 Three 10-bit unsigned normalized values, and 2 padding bits.
i16 One 16-bit signed integer.
i16x2 Two 16-bit signed integers.
i16x4 Four 16-bit signed integers.
u16 One 16-bit unsigned integer.
u16x2 Two 16-bit unsigned integers.
u16x4 Four 16-bit unsigned integers.
sn16x2 Two 16-bit signed normalized values.
sn16x4 Four 16-bit signed normalized values.
un16x2 Two 16-bit unsigned normalized values.
un16x4 Four 16-bit unsigned normalized values.
i32 One 32-bit signed integer (aka int).
i32x2 Two 32-bit signed integers.
i32x3 Three 32-bit signed integers.
i32x4 Four 32-bit signed integers.
u32 One 32-bit unsigned integer (aka uint).
u32x2 Two 32-bit unsigned integers.
u32x3 Three 32-bit unsigned integers.
u32x4 Four 32-bit unsigned integers.
f16x2 Two 16-bit floating point numbers.
f16x4 Four 16-bit floating point numbers.
f32 One 32-bit floating point number (aka float).
f32x2 Two 32-bit floating point numbers (aka vec2).
f32x3 Three 32-bit floating point numbers (aka vec3).
f32x4 Four 32-bit floating point numbers (aka vec4).
mat2 A 2x2 matrix containing four 32-bit floats.
mat3 A 3x3 matrix containing nine 32-bit floats.
mat4 A 4x4 matrix containing sixteen 32-bit floats.
index16 Like u16, but 1-indexed.
index32 Like u32, but 1-indexed.

Notes

In addition to these values, the following aliases can be used:

Alias Maps to
vec2 f32x2
vec3 f32x3
vec4 f32x4
int i32
uint u32
float f32
color un8x4

Additionally, the following convenience rules apply:

So you can write, e.g. lovr.graphics.newBuffer(4, 'floats'), which is cute!

See also