No matching definitions.

opengl/math

src/opengl/math.tur
defn

mat4-identity

(mat4-identity :int)

return a 4x4 identity matrix.

Opaque :int handle to a heap-allocated 16-float identity matrix.

(mat4-identity)  ; => :int mat4 handle

Since: v0.1.0

defn

mat4-perspective

(mat4-perspective [fovy :float aspect :float near :float far :float] :int)

build a perspective projection matrix.

fovyvertical field-of-view in radians (e.g. 0.785 = 45 degrees)
aspectviewport width / height ratio
nearnear clip plane distance (positive)
farfar clip plane distance (positive, > near)

Opaque :int mat4 handle.

(mat4-perspective 0.785 (/ 800.0 600.0) 0.1 100.0)

Since: v0.1.0

defn

mat4-look-at

(mat4-look-at [ex :float ey :float ez :float cx :float cy :float cz :float ux :float uy :float uz :float] :int)

build a view matrix using eye/center/up vectors.

ex ey ez -- eye position
cx cy cz -- look-at target position
ux uy uz -- world up vector (usually 0 1 0)

Opaque :int mat4 handle.

(mat4-look-at 0.0 0.0 3.0  0.0 0.0 0.0  0.0 1.0 0.0)

Since: v0.1.0

defn

mat4-translate

(mat4-translate [tx :float ty :float tz :float] :int)

build a translation matrix.

tx ty tz -- translation vector

Opaque :int mat4 handle.

(mat4-translate 0.0 0.0 -5.0)

Since: v0.1.0

defn

mat4-rotate-x

(mat4-rotate-x [angle :float] :int)

build a rotation matrix around the X axis.

anglerotation angle in radians

Opaque :int mat4 handle.

Since: v0.1.0

defn

mat4-rotate-y

(mat4-rotate-y [angle :float] :int)

build a rotation matrix around the Y axis.

anglerotation angle in radians

Opaque :int mat4 handle.

(mat4-rotate-y (ref-get angle))

Since: v0.1.0

defn

mat4-rotate-z

(mat4-rotate-z [angle :float] :int)

build a rotation matrix around the Z axis.

anglerotation angle in radians

Since: v0.1.0

defn

mat4-mul

(mat4-mul [a :int b :int] :int)

multiply two mat4 matrices (result = a * b).

aleft mat4 handle
bright mat4 handle

New heap-allocated mat4 handle with the product.

(mat4-mul projection (mat4-mul view model))

Since: v0.1.0

defn

mat4-ptr

(mat4-ptr [mat :int] :int)

return the raw float* pointer to a mat4 for uniform upload.

matmat4 handle from any mat4-* function

Opaque :int raw float pointer (pass directly to set-uniform-mat4).

(set-uniform-mat4 prog "model" (mat4-ptr model))

Since: v0.1.0

defn

normal-mat4

(normal-mat4 [model :int] :int)

compute the normal matrix from a model matrix.

modelmodel mat4 handle

New heap-allocated mat4 handle for use as the normal matrix uniform.

(set-uniform-mat4 prog "normalMatrix" (mat4-ptr (normal-mat4 model)))

Since: v0.1.0