Skip to content
modkitv0.2

math/types.h

#include <modkit/math/types.h>10 functions · 5 structs · 5 typedefs · 18 macros

Core math types for GPU rendering.

All types are simple float arrays that can be:Passed directly to GPU functions via .data memberUsed with cglm inline functions via .v or .m memberInitialized with compound literal macros Column-major matrix layout (OpenGL convention): [0] [4] [8] [12] col0 col1 col2 col3 [1] [5] [9] [13] = Xx Yx Zx Tx [2] [6] [10] [14] Xy Yy Zy Ty [3] [7] [11] [15] Xz Yz Zz Tz Translation is at indices [12, 13, 14]

Functions

mk_mat4_cptrfunction

const float * mk_mat4_cptr(const mk_mat4 *m)

Perform the mat4 cptr operation.

ParameterTypeDescription
mconst mk_mat4 *Value for m.

Returns A borrowed pointer, or NULL when unavailable.

mk_mat4_ptrfunction

float * mk_mat4_ptr(mk_mat4 *m)

Perform the mat4 ptr operation.

ParameterTypeDescription
mmk_mat4 *Value for m.

Returns A borrowed pointer, or NULL when unavailable.

mk_quat_cptrfunction

const float * mk_quat_cptr(const mk_quat *q)

Perform the quat cptr operation.

ParameterTypeDescription
qconst mk_quat *Value for q.

Returns A borrowed pointer, or NULL when unavailable.

mk_quat_ptrfunction

float * mk_quat_ptr(mk_quat *q)

Perform the quat ptr operation.

ParameterTypeDescription
qmk_quat *Value for q.

Returns A borrowed pointer, or NULL when unavailable.

mk_vec2_cptrfunction

const float * mk_vec2_cptr(const mk_vec2 *v)

Perform the vec2 cptr operation.

ParameterTypeDescription
vconst mk_vec2 *Value for v.

Returns A borrowed pointer, or NULL when unavailable.

mk_vec2_ptrfunction

float * mk_vec2_ptr(mk_vec2 *v)

Perform the vec2 ptr operation.

ParameterTypeDescription
vmk_vec2 *Value for v.

Returns A borrowed pointer, or NULL when unavailable.

mk_vec3_cptrfunction

const float * mk_vec3_cptr(const mk_vec3 *v)

Perform the vec3 cptr operation.

ParameterTypeDescription
vconst mk_vec3 *Value for v.

Returns A borrowed pointer, or NULL when unavailable.

mk_vec3_ptrfunction

float * mk_vec3_ptr(mk_vec3 *v)

Perform the vec3 ptr operation.

ParameterTypeDescription
vmk_vec3 *Value for v.

Returns A borrowed pointer, or NULL when unavailable.

mk_vec4_cptrfunction

const float * mk_vec4_cptr(const mk_vec4 *v)

Perform the vec4 cptr operation.

ParameterTypeDescription
vconst mk_vec4 *Value for v.

Returns A borrowed pointer, or NULL when unavailable.

mk_vec4_ptrfunction

float * mk_vec4_ptr(mk_vec4 *v)

Perform the vec4 ptr operation.

ParameterTypeDescription
vmk_vec4 *Value for v.

Returns A borrowed pointer, or NULL when unavailable.

Structs

mk_mat4struct

4x4 matrix (column-major)

FieldTypeDescription
datafloatThe data.
colfloatcol[column][row]
mmat4cglm compatibility

mk_quatstruct

Quaternion for rotations Stored as [x, y, z, w] (imaginary first, real/scalar last) - cglm convention.

FieldTypeDescription
xfloatImaginary X component.
yfloatImaginary Y component.
zfloatImaginary Z component.
wfloatReal scalar component.
datafloatThe data.
qversorcglm compatibility

mk_vec2struct

2D vector (position, UV coordinates, etc.)

FieldTypeDescription
xfloatX component.
yfloatY component.
datafloatThe data.
vvec2cglm compatibility

mk_vec3struct

3D vector (position, direction, scale, etc.)

FieldTypeDescription
xfloatX component.
yfloatY component.
zfloatZ component.
datafloatThe data.
vvec3cglm compatibility

mk_vec4struct

4D vector (homogeneous coordinates, colors, planes)

FieldTypeDescription
xfloatX component.
yfloatY component.
zfloatZ component.
wfloatW component.
datafloatThe data.
vvec4cglm compatibility

Typedefs

mk_mat4typedef

typedef struct mk_mat4 mk_mat4

4x4 matrix (column-major)

mk_quattypedef

typedef struct mk_quat mk_quat

Quaternion for rotations Stored as [x, y, z, w] (imaginary first, real/scalar last) - cglm convention.

mk_vec2typedef

typedef struct mk_vec2 mk_vec2

2D vector (position, UV coordinates, etc.)

mk_vec3typedef

typedef struct mk_vec3 mk_vec3

3D vector (position, direction, scale, etc.)

mk_vec4typedef

typedef struct mk_vec4 mk_vec4

4D vector (homogeneous coordinates, colors, planes)

Macros

MK_MAT4_IDENTITYdefine

MK_MAT4_IDENTITY

Constant for mat4 identity.

MK_QUATdefine

MK_QUAT(qx, qy, qz, qw)

Constant for quat.

MK_QUAT_IDENTITYdefine

MK_QUAT_IDENTITY

Constant for quat identity.

MK_VEC2define

MK_VEC2(px, py)

Constant for vec2.

MK_VEC2_ONEdefine

MK_VEC2_ONE

Constant for vec2 one.

MK_VEC2_ZEROdefine

MK_VEC2_ZERO

Constant for vec2 zero.

MK_VEC3define

MK_VEC3(px, py, pz)

Constant for vec3.

MK_VEC3_BACKdefine

MK_VEC3_BACK

Constant for vec3 back.

MK_VEC3_DOWNdefine

MK_VEC3_DOWN

Constant for vec3 down.

MK_VEC3_FORWARDdefine

MK_VEC3_FORWARD

Constant for vec3 forward.

MK_VEC3_LEFTdefine

MK_VEC3_LEFT

Constant for vec3 left.

MK_VEC3_ONEdefine

MK_VEC3_ONE

Constant for vec3 one.

MK_VEC3_RIGHTdefine

MK_VEC3_RIGHT

Constant for vec3 right.

MK_VEC3_UPdefine

MK_VEC3_UP

Constant for vec3 up.

MK_VEC3_ZEROdefine

MK_VEC3_ZERO

Constant for vec3 zero.

MK_VEC4define

MK_VEC4(px, py, pz, pw)

Constant for vec4.

MK_VEC4_ONEdefine

MK_VEC4_ONE

Constant for vec4 one.

MK_VEC4_ZEROdefine

MK_VEC4_ZERO

Constant for vec4 zero.