API Reference › Types › floats
type

floats

floats / doubles

floats(n) allocates room for n float values and returns a floats buffer; doubles(n) does the same for double. Index it with v[i] to read or write an element, with no bounds checking. The memory is exactly what a GPU vertex or uniform buffer expects, so a floats buffer uploads as it is.

Example

program Vertices {
  entry {
    let v = floats(6)
    v[0] = 0.0;  v[1] = 0.5
    v[2] = -0.5; v[3] = -0.5
    v[4] = 0.5;  v[5] = -0.5
    print(v[1] - v[3])                 # 1.0
  }
}
← All symbols