No matching definitions.

opengl/arrays

src/opengl/arrays.tur

packed GLfloat arrays for buffer uploads.

Since: v0.2.0

defopaque

FloatArray

(FloatArray)

opaque handle to a heap block of packed 32-bit floats.

defn

make-float-array

(make-float-array [n : int] :)

allocate a zeroed array of n packed float32 slots.

nnumber of float slots (a negative n is treated as 0)

A FloatArray that must be consumed exactly once by delete-float-array.

(let [a (make-float-array 9)]
    (float-array-set! a 0 0.6)
    (delete-float-array a))

Since: v0.2.0

defn

delete-float-array

(delete-float-array [a : FloatArray] :)

free an array, consuming the handle.

athe array to release
(delete-float-array a)

Since: v0.2.0

defn

float-array-set!

(float-array-set! [^borrow a : FloatArray i : int v : float] :)

store v at index i, narrowed to float32.

athe array (borrowed)
islot index; out of range is a no-op
vthe value, narrowed from float64 to GLfloat
(float-array-set! a 2 7.1)

Since: v0.2.0

defn

float-array-get

(float-array-get [^borrow a : FloatArray i : int] :)

read slot i, widened back to float64.

athe array (borrowed)
islot index; out of range answers 0.0

The stored value. Note it round-trips through float32, so it is the nearest GLfloat to what was written, not the original float64.

(float-array-get a 2)   ; => 7.1

Since: v0.2.0

defn

float-array-len

(float-array-len [^borrow a : FloatArray] :)

number of float slots.

athe array (borrowed)

The slot count passed to make-float-array.

(float-array-len a)   ; => 9

Since: v0.2.0

defn

float-array-bytes

(float-array-bytes [^borrow a : FloatArray] :)

payload size in bytes, for upload-vertices.

athe array (borrowed)

len * 4 -- the byte size GL wants alongside the pointer.

(upload-vertices (float-array-ptr a) (float-array-bytes a) ":static-draw")

Since: v0.2.0

defn

float-array-ptr

(float-array-ptr [^borrow a : FloatArray] :)

address of the packed payload.

athe array (borrowed)

An :int pointer valid until delete-float-array. Pass it to upload-vertices; do not retain it past the array's lifetime.

(upload-vertices (float-array-ptr a) (float-array-bytes a) ":static-draw")

Since: v0.2.0

defmacro

with-float-array

(with-float-array [a n & body])

allocate an array for the duration of body, then free

asymbol to bind the FloatArray handle
nnumber of float slots
bodyone or more expressions executed with a in scope
(with-float-array verts 9
    (float-array-set! verts 0 0.6)
    (upload-vertices (float-array-ptr verts)
                     (float-array-bytes verts) ":static-draw"))

Since: v0.2.0

Internal definitions
__fa-alloc-- calloc a length header plus n float32 slots.
__fa-free-- release a block from __fa-alloc.
__fa-len-- read the length header.
__fa-set!-- bounds-checked narrowing store.
__fa-get-- bounds-checked widening load.
__fa-data-- address of the payload, past the length header.