Skip to content
modkitv0.2

draw3d.h

#include <modkit/draw3d.h>77 functions ยท 1 enums ยท 2 typedefs ยท 1 macros

Context-based immediate-mode 3D shape drawing.

Provides 3D primitive rendering using transient buffers. Usage:

Functions

mk_axesfunction

void mk_axes(float length)

Draw axes at origin.

ParameterTypeDescription
lengthfloatValue for length.

mk_axes_atfunction

void mk_axes_at(mk_vec3 pos, float length)

Draw axes at position.

ParameterTypeDescription
posmk_vec3Value for pos.
lengthfloatValue for length.

mk_boxfunction

void mk_box(mk_vec3 pos, mk_vec3 size, uint32_t color)

Draw box at position.

ParameterTypeDescription
posmk_vec3Value for pos.
sizemk_vec3Size in bytes.
coloruint32_tValue for color.

mk_box_rotfunction

void mk_box_rot(mk_vec3 pos, mk_vec3 size, mk_vec3 rot, uint32_t color)

Draw box with rotation (euler radians).

ParameterTypeDescription
posmk_vec3Value for pos.
sizemk_vec3Size in bytes.
rotmk_vec3Value for rot.
coloruint32_tValue for color.

mk_cam_clipfunction

void mk_cam_clip(float near, float far)

Set camera clip planes.

ParameterTypeDescription
nearfloatValue for near.
farfloatValue for far.

mk_cam_fovfunction

void mk_cam_fov(float degrees)

Set camera field of view (degrees).

ParameterTypeDescription
degreesfloatValue for degrees.

mk_cam_getfunction

mk_camera * mk_cam_get(void)

Get internal camera for advanced use.

Returns A borrowed pointer, or NULL when unavailable.

mk_cam_lookatfunction

void mk_cam_lookat(mk_vec3 eye, mk_vec3 target)

Set camera position and target.

ParameterTypeDescription
eyemk_vec3Value for eye.
targetmk_vec3Value for target.

mk_cam_lookat_upfunction

void mk_cam_lookat_up(mk_vec3 eye, mk_vec3 target, mk_vec3 up)

Set camera with up vector.

ParameterTypeDescription
eyemk_vec3Value for eye.
targetmk_vec3Value for target.
upmk_vec3Value for up.

mk_cam_orbitfunction

void mk_cam_orbit(float distance, float yaw, float pitch)

Orbit camera around origin.

ParameterTypeDescription
distancefloatValue for distance.
yawfloatValue for yaw.
pitchfloatValue for pitch.

mk_cam_setfunction

void mk_cam_set(const mk_camera *cam)

Set custom camera.

ParameterTypeDescription
camconst mk_camera *Value for cam.

mk_clearfunction

void mk_clear(uint32_t color)

Clear screen with color (0xRRGGBBAA).

ParameterTypeDescription
coloruint32_tValue for color.

mk_conefunction

void mk_cone(mk_vec3 pos, float radius, float height, uint32_t color)

Draw cone at position.

ParameterTypeDescription
posmk_vec3Value for pos.
radiusfloatValue for radius.
heightfloatValue for height.
coloruint32_tValue for color.

mk_cubefunction

void mk_cube(mk_vec3 pos, float size, uint32_t color)

Draw cube at position.

ParameterTypeDescription
posmk_vec3Value for pos.
sizefloatSize in bytes.
coloruint32_tValue for color.

mk_cube_rotfunction

void mk_cube_rot(mk_vec3 pos, float size, mk_vec3 rot, uint32_t color)

Draw cube with rotation (euler radians).

ParameterTypeDescription
posmk_vec3Value for pos.
sizefloatSize in bytes.
rotmk_vec3Value for rot.
coloruint32_tValue for color.

mk_cylinderfunction

void mk_cylinder(mk_vec3 pos, float radius, float height, uint32_t color)

Draw cylinder at position.

ParameterTypeDescription
posmk_vec3Value for pos.
radiusfloatValue for radius.
heightfloatValue for height.
coloruint32_tValue for color.

mk_draw3d_aabbfunction

void mk_draw3d_aabb(mk_draw3d_ctx_t ctx, float min_x, float min_y, float min_z, float max_x, float max_y, float max_z, uint32_t color)

Draw an axis-aligned bounding box (AABB).

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
min_xfloatMinimum corner
min_yfloatMinimum corner
min_zfloatMinimum corner
max_xfloatMaximum corner
max_yfloatMaximum corner
max_zfloatMaximum corner
coloruint32_tRGBA color

mk_draw3d_arcfunction

void mk_draw3d_arc(mk_draw3d_ctx_t ctx, float cx, float cy, float cz, float radius, float nx, float ny, float nz, float start_angle, float end_angle, uint32_t color, int segments)

Draw an arc in 3D space.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
cxfloatCenter position
cyfloatCenter position
czfloatCenter position
radiusfloatArc radius
nxfloatNormal direction
nyfloatNormal direction
nzfloatNormal direction
start_anglefloatStart angle in radians
end_anglefloatEnd angle in radians
coloruint32_tRGBA color
segmentsintNumber of segments (0 = auto)

mk_draw3d_arrowfunction

void mk_draw3d_arrow(mk_draw3d_ctx_t ctx, float x1, float y1, float z1, float x2, float y2, float z2, float head_size, uint32_t color)

Draw an arrow from start to end point.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
x1floatStart point
y1floatStart point
z1floatStart point
x2floatEnd point (arrow tip)
y2floatEnd point (arrow tip)
z2floatEnd point (arrow tip)
head_sizefloatArrow head size (0 = auto, based on length)
coloruint32_tRGBA color

mk_draw3d_axesfunction

void mk_draw3d_axes(mk_draw3d_ctx_t ctx, float length)

Draw coordinate axes at origin.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
lengthfloatLength of each axis

mk_draw3d_beginfunction

void mk_draw3d_begin(mk_draw3d_ctx_t ctx, mk_encoder_t encoder, mk_view_id_t view, const float *view_mtx, const float *proj_mtx)

Begin 3D drawing mode.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
encodermk_encoder_tEncoder from mk_encoder_begin()
viewmk_view_id_tView ID to draw to
view_mtxconst float *4x4 view matrix (column-major)
proj_mtxconst float *4x4 projection matrix (column-major)

mk_draw3d_bezierfunction

void mk_draw3d_bezier(mk_draw3d_ctx_t ctx, const float *p0, const float *p1, const float *p2, const float *p3, uint32_t color, int segments)

Draw a Bezier curve in 3D.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
p0const float *Start point (float3)
p1const float *Control point 1 (float3)
p2const float *Control point 2 (float3)
p3const float *End point (float3)
coloruint32_tRGBA color
segmentsintNumber of segments (0 = auto)

mk_draw3d_billboardfunction

void mk_draw3d_billboard(mk_draw3d_ctx_t ctx, float x, float y, float z, float width, float height, mk_texture_t texture, uint32_t tint)

Draw a billboard sprite at a 3D position.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
xfloatWorld position
yfloatWorld position
zfloatWorld position
widthfloatSize in world units
heightfloatSize in world units
texturemk_texture_tSprite texture
tintuint32_tTint color (0xFFFFFFFF for no tint)

mk_draw3d_billboard_quadfunction

void mk_draw3d_billboard_quad(mk_draw3d_ctx_t ctx, float x, float y, float z, float width, float height, uint32_t color)

Draw a colored billboard quad (no texture).

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
xfloatWorld position
yfloatWorld position
zfloatWorld position
widthfloatSize in world units
heightfloatSize in world units
coloruint32_tRGBA color

mk_draw3d_billboard_uvfunction

void mk_draw3d_billboard_uv(mk_draw3d_ctx_t ctx, float x, float y, float z, float width, float height, mk_texture_t texture, float u0, float v0, float u1, float v1, uint32_t tint)

Draw a billboard sprite with UV coordinates.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
xfloatWorld position
yfloatWorld position
zfloatWorld position
widthfloatSize in world units
heightfloatSize in world units
texturemk_texture_tSprite texture
u0floatUV coordinates (0-1)
v0floatUV coordinates (0-1)
u1floatUV coordinates (0-1)
v1floatUV coordinates (0-1)
tintuint32_tTint color

mk_draw3d_bounding_spherefunction

void mk_draw3d_bounding_sphere(mk_draw3d_ctx_t ctx, float cx, float cy, float cz, float radius, uint32_t color, int rings)

Draw a bounding sphere (wireframe).

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
cxfloatCenter
cyfloatCenter
czfloatCenter
radiusfloatRadius
coloruint32_tRGBA color
ringsintNumber of rings (0 = auto, typically 3)

mk_draw3d_boxfunction

void mk_draw3d_box(mk_draw3d_ctx_t ctx, float w, float h, float d, uint32_t color)

Draw a box (rectangular cuboid) centered at origin.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
wfloatWidth (X axis)
hfloatHeight (Y axis)
dfloatDepth (Z axis)
coloruint32_tRGBA color (0xRRGGBBAA)

mk_draw3d_capsulefunction

void mk_draw3d_capsule(mk_draw3d_ctx_t ctx, float radius, float height, uint32_t color, int segments)

Draw a capsule (cylinder with hemispherical caps) along Y axis.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
radiusfloatRadius of cylinder and caps
heightfloatTotal height (including caps)
coloruint32_tRGBA color (0xRRGGBBAA)
segmentsintNumber of radial segments, 0 = auto

mk_draw3d_catmull_romfunction

void mk_draw3d_catmull_rom(mk_draw3d_ctx_t ctx, const float *points, int point_count, uint32_t color, int segments_per_curve)

Draw a Catmull-Rom spline through points.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
pointsconst float *Array of float3 control points
point_countintNumber of control points (minimum 4)
coloruint32_tRGBA color
segments_per_curveintSegments between each pair of control points

mk_draw3d_circlefunction

void mk_draw3d_circle(mk_draw3d_ctx_t ctx, float cx, float cy, float cz, float radius, float nx, float ny, float nz, uint32_t color, int segments)

Draw a circle in 3D space.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
cxfloatCenter position
cyfloatCenter position
czfloatCenter position
radiusfloatCircle radius
nxfloatNormal direction (determines orientation)
nyfloatNormal direction (determines orientation)
nzfloatNormal direction (determines orientation)
coloruint32_tRGBA color
segmentsintNumber of segments (0 = auto)

mk_draw3d_conefunction

void mk_draw3d_cone(mk_draw3d_ctx_t ctx, float radius, float height, uint32_t color, int segments)

Draw a cone with apex at origin, base along negative Y axis.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
radiusfloatBase radius
heightfloatCone height
coloruint32_tRGBA color (0xRRGGBBAA)
segmentsintNumber of radial segments, 0 = auto

mk_draw3d_crossfunction

void mk_draw3d_cross(mk_draw3d_ctx_t ctx, float x, float y, float z, float size, uint32_t color)

Draw a cross/marker at a point.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
xfloatPosition
yfloatPosition
zfloatPosition
sizefloatSize of the cross arms
coloruint32_tRGBA color

mk_draw3d_ctx_createfunction

mk_draw3d_ctx_t mk_draw3d_ctx_create(void)

Create a new draw3d context.

Each context has its own batch buffers and state.

Returns Context handle, or MK_DRAW3D_CTX_INVALID on failure

mk_draw3d_ctx_destroyfunction

void mk_draw3d_ctx_destroy(mk_draw3d_ctx_t ctx)

Destroy a draw3d context.

Context must not be in draw mode.

ParameterTypeDescription
ctxmk_draw3d_ctx_tActive operation context.

mk_draw3d_cubefunction

void mk_draw3d_cube(mk_draw3d_ctx_t ctx, float size, uint32_t color)

Draw a cube centered at origin.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
sizefloatSide length
coloruint32_tRGBA color (0xRRGGBBAA)

mk_draw3d_cylinderfunction

void mk_draw3d_cylinder(mk_draw3d_ctx_t ctx, float radius, float height, uint32_t color, int segments)

Draw a cylinder centered at origin, aligned along Y axis.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
radiusfloatCylinder radius
heightfloatCylinder height
coloruint32_tRGBA color (0xRRGGBBAA)
segmentsintNumber of radial segments, 0 = auto

mk_draw3d_default_ctxfunction

mk_draw3d_ctx_t mk_draw3d_default_ctx(void)

Get default draw3d context (auto-created).

Returns The resulting handle or value.

mk_draw3d_default_viewfunction

mk_view_id_t mk_draw3d_default_view(void)

Get default 3D view ID.

Returns The resulting handle or value.

mk_draw3d_discfunction

void mk_draw3d_disc(mk_draw3d_ctx_t ctx, float cx, float cy, float cz, float radius, float nx, float ny, float nz, uint32_t color, int segments)

Draw a filled disc in 3D space.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
cxfloatCenter position
cyfloatCenter position
czfloatCenter position
radiusfloatDisc radius
nxfloatNormal direction
nyfloatNormal direction
nzfloatNormal direction
coloruint32_tRGBA color
segmentsintNumber of segments (0 = auto)

mk_draw3d_endfunction

void mk_draw3d_end(mk_draw3d_ctx_t ctx)

End 3D drawing mode and flush all batched draws.

ParameterTypeDescription
ctxmk_draw3d_ctx_tActive operation context.

mk_draw3d_flushfunction

void mk_draw3d_flush(void)

Flush pending simple API draws (called automatically at frame end).

mk_draw3d_frustumfunction

void mk_draw3d_frustum(mk_draw3d_ctx_t ctx, const float *inv_view_proj, uint32_t color)

Draw a view frustum from inverse view-projection matrix.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
inv_view_projconst float *Inverse of view*projection matrix
coloruint32_tRGBA color

mk_draw3d_gizmo_rotatefunction

void mk_draw3d_gizmo_rotate(mk_draw3d_ctx_t ctx, float x, float y, float z, float size)

Draw a rotation gizmo (3 circles).

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
xfloatPosition
yfloatPosition
zfloatPosition
sizefloatGizmo size

mk_draw3d_gizmo_scalefunction

void mk_draw3d_gizmo_scale(mk_draw3d_ctx_t ctx, float x, float y, float z, float size)

Draw a scale gizmo (3 lines with cubes).

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
xfloatPosition
yfloatPosition
zfloatPosition
sizefloatGizmo size

mk_draw3d_gizmo_translatefunction

void mk_draw3d_gizmo_translate(mk_draw3d_ctx_t ctx, float x, float y, float z, float size)

Draw a translation gizmo (3 arrows).

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
xfloatPosition
yfloatPosition
zfloatPosition
sizefloatGizmo size

mk_draw3d_gridfunction

void mk_draw3d_grid(mk_draw3d_ctx_t ctx, float size, int divisions, uint32_t color)

Draw a grid in the XZ plane centered at origin.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
sizefloatTotal size of grid (side length)
divisionsintNumber of divisions per axis
coloruint32_tRGBA color (0xRRGGBBAA)

mk_draw3d_initfunction

bool mk_draw3d_init(void)

Initialize shared 3D drawing resources (called automatically on first use).

Returns true on success

mk_draw3d_light_directionalfunction

void mk_draw3d_light_directional(mk_draw3d_ctx_t ctx, float x, float y, float z, float dx, float dy, float dz, float size, uint32_t color)

Draw a directional light gizmo.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
xfloatGizmo position
yfloatGizmo position
zfloatGizmo position
dxfloatLight direction
dyfloatLight direction
dzfloatLight direction
sizefloatGizmo size
coloruint32_tLight color

mk_draw3d_light_pointfunction

void mk_draw3d_light_point(mk_draw3d_ctx_t ctx, float x, float y, float z, float radius, uint32_t color)

Draw a point light gizmo.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
xfloatLight position
yfloatLight position
zfloatLight position
radiusfloatLight radius
coloruint32_tLight color

mk_draw3d_light_spotfunction

void mk_draw3d_light_spot(mk_draw3d_ctx_t ctx, float x, float y, float z, float dx, float dy, float dz, float range, float inner_angle, float outer_angle, uint32_t color)

Draw a spot light gizmo.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
xfloatLight position
yfloatLight position
zfloatLight position
dxfloatLight direction
dyfloatLight direction
dzfloatLight direction
rangefloatLight range
inner_anglefloatInner cone angle (radians)
outer_anglefloatOuter cone angle (radians)
coloruint32_tLight color

mk_draw3d_linefunction

void mk_draw3d_line(mk_draw3d_ctx_t ctx, float x1, float y1, float z1, float x2, float y2, float z2, uint32_t color)

Draw a 3D line.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
x1floatStart point
y1floatStart point
z1floatStart point
x2floatEnd point
y2floatEnd point
z2floatEnd point
coloruint32_tRGBA color (0xRRGGBBAA)

mk_draw3d_obbfunction

void mk_draw3d_obb(mk_draw3d_ctx_t ctx, const float *center, const float *half_extents, const float *rotation, uint32_t color)

Draw an oriented bounding box (OBB).

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
centerconst float *3-element center position
half_extentsconst float *3-element half sizes
rotationconst float *4x4 rotation matrix (or full transform)
coloruint32_tRGBA color

mk_draw3d_planefunction

void mk_draw3d_plane(mk_draw3d_ctx_t ctx, float width, float depth, uint32_t color)

Draw a plane (quad) in the XZ plane, centered at origin.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
widthfloatWidth (X axis)
depthfloatDepth (Z axis)
coloruint32_tRGBA color (0xRRGGBBAA)

mk_draw3d_pointfunction

void mk_draw3d_point(mk_draw3d_ctx_t ctx, float x, float y, float z, float size, uint32_t color)

Draw a point (small sphere or cross based on size).

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
xfloatPosition
yfloatPosition
zfloatPosition
sizefloatPoint size in world units
coloruint32_tRGBA color

mk_draw3d_polylinefunction

void mk_draw3d_polyline(mk_draw3d_ctx_t ctx, const float *points, int point_count, uint32_t color, bool closed)

Draw a polyline through multiple points.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
pointsconst float *Array of float3 positions (x,y,z,x,y,z,...)
point_countintNumber of points
coloruint32_tRGBA color
closedbooltrue to connect last point to first

mk_draw3d_polyline_coloredfunction

void mk_draw3d_polyline_colored(mk_draw3d_ctx_t ctx, const float *points, const uint32_t *colors, int point_count, bool closed)

Draw a colored polyline (each segment can have different color).

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
pointsconst float *Array of float3 positions
colorsconst uint32_t *Array of RGBA colors (one per point)
point_countintNumber of points
closedbooltrue to connect last to first

mk_draw3d_pop_transformfunction

void mk_draw3d_pop_transform(mk_draw3d_ctx_t ctx)

Pop transform from stack.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle

mk_draw3d_prepare_viewfunction

bool mk_draw3d_prepare_view(mk_view_id_t view, const float *view_mtx, const float *proj_mtx)

Configure a 3D view on the API thread before encoder submission.

ParameterTypeDescription
viewmk_view_id_tValue for view.
view_mtxconst float *Value for view mtx.
proj_mtxconst float *Value for proj mtx.

Returns True when the operation succeeds.

mk_draw3d_push_transformfunction

void mk_draw3d_push_transform(mk_draw3d_ctx_t ctx, const float *mtx)

Push current transform onto stack and set new transform.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
mtxconst float *4x4 model matrix (column-major), NULL for identity

mk_draw3d_rayfunction

void mk_draw3d_ray(mk_draw3d_ctx_t ctx, float ox, float oy, float oz, float dx, float dy, float dz, float length, uint32_t color)

Draw a ray (line with arrow at start).

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
oxfloatOrigin point
oyfloatOrigin point
ozfloatOrigin point
dxfloatDirection (normalized)
dyfloatDirection (normalized)
dzfloatDirection (normalized)
lengthfloatRay length
coloruint32_tRGBA color

mk_draw3d_set_billboard_modefunction

void mk_draw3d_set_billboard_mode(mk_draw3d_ctx_t ctx, mk_billboard_mode mode)

Set billboard mode for subsequent sprite draws.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
modemk_billboard_modeBillboard mode

mk_draw3d_set_transformfunction

void mk_draw3d_set_transform(mk_draw3d_ctx_t ctx, const float *mtx)

Set model transform for subsequent primitives.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
mtxconst float *4x4 model matrix (column-major), NULL for identity

mk_draw3d_shutdownfunction

void mk_draw3d_shutdown(void)

Shutdown shared 3D drawing resources (call at program exit).

mk_draw3d_spherefunction

void mk_draw3d_sphere(mk_draw3d_ctx_t ctx, float radius, uint32_t color, int segments)

Draw a UV sphere centered at origin.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
radiusfloatSphere radius
coloruint32_tRGBA color (0xRRGGBBAA)
segmentsintNumber of segments (latitude and longitude), 0 = auto

mk_draw3d_textfunction

void mk_draw3d_text(mk_draw3d_ctx_t ctx, float x, float y, float z, const char *text, uint32_t color, float scale)

Draw text at a 3D position (billboard style).

Uses the default debug font.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
xfloatWorld position
yfloatWorld position
zfloatWorld position
textconst char *Text string
coloruint32_tRGBA color
scalefloatText scale (1.0 = default size)

mk_draw3d_textffunction

void mk_draw3d_textf(mk_draw3d_ctx_t ctx, float x, float y, float z, uint32_t color, float scale, const char *fmt,...)

Draw formatted text at a 3D position.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
xfloatWorld position
yfloatWorld position
zfloatWorld position
coloruint32_tRGBA color
scalefloatText scale
fmtconst char *Format string
...โ€”

mk_draw3d_torusfunction

void mk_draw3d_torus(mk_draw3d_ctx_t ctx, float major_r, float minor_r, uint32_t color, int major_seg, int minor_seg)

Draw a torus centered at origin in XZ plane.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
major_rfloatMajor radius (center to tube center)
minor_rfloatMinor radius (tube radius)
coloruint32_tRGBA color (0xRRGGBBAA)
major_segintMajor segments (around the ring), 0 = auto
minor_segintMinor segments (around the tube), 0 = auto

mk_draw3d_vectorfunction

void mk_draw3d_vector(mk_draw3d_ctx_t ctx, float px, float py, float pz, float dx, float dy, float dz, float length, uint32_t color)

Draw a direction vector from a point.

ParameterTypeDescription
ctxmk_draw3d_ctx_tContext handle
pxfloatOrigin point
pyfloatOrigin point
pzfloatOrigin point
dxfloatDirection (will be normalized)
dyfloatDirection (will be normalized)
dzfloatDirection (will be normalized)
lengthfloatLength of the arrow
coloruint32_tRGBA color

mk_dtfunction

float mk_dt(void)

Get delta time since last frame (seconds).

Returns The resulting value.

mk_gridfunction

void mk_grid(int divisions, float spacing)

Draw grid in XZ plane.

ParameterTypeDescription
divisionsintValue for divisions.
spacingfloatValue for spacing.

mk_grid_colorfunction

void mk_grid_color(int divisions, float spacing, uint32_t color)

Draw grid with color.

ParameterTypeDescription
divisionsintValue for divisions.
spacingfloatValue for spacing.
coloruint32_tValue for color.

mk_linefunction

void mk_line(mk_vec3 start, mk_vec3 end, uint32_t color)

Draw 3D line.

ParameterTypeDescription
startmk_vec3Value for start.
endmk_vec3Value for end.
coloruint32_tValue for color.

mk_planefunction

void mk_plane(mk_vec3 pos, float width, float depth, uint32_t color)

Draw plane at position.

ParameterTypeDescription
posmk_vec3Value for pos.
widthfloatValue for width.
depthfloatValue for depth.
coloruint32_tValue for color.

mk_spherefunction

void mk_sphere(mk_vec3 pos, float radius, uint32_t color)

Draw sphere at position.

ParameterTypeDescription
posmk_vec3Value for pos.
radiusfloatValue for radius.
coloruint32_tValue for color.

mk_text3dfunction

void mk_text3d(mk_vec3 pos, const char *text, uint32_t color)

Draw text label at 3D position (projects to screen).

ParameterTypeDescription
posmk_vec3Value for pos.
textconst char *Value for text.
coloruint32_tValue for color.

mk_text3dffunction

void mk_text3df(mk_vec3 pos, uint32_t color, const char *fmt,...)

Draw formatted text label at 3D position.

ParameterTypeDescription
posmk_vec3Value for pos.
coloruint32_tValue for color.
fmtconst char *Value for fmt.
...โ€”

mk_timefunction

float mk_time(void)

Get elapsed time since app start (seconds).

Returns The resulting value.

Enums

mk_billboard_modeenum

Billboard mode for sprites.

ValueDescription
MK_BILLBOARD_SCREENAlways face screen (UI-like).
MK_BILLBOARD_WORLDFace camera but stay upright (Y-up).
MK_BILLBOARD_AXISRotate around specified axis.

Typedefs

mk_billboard_modetypedef

typedef enum mk_billboard_mode mk_billboard_mode

Billboard mode for sprites.

mk_draw3d_ctx_ttypedef

typedef struct mk_draw3d_ctx* mk_draw3d_ctx_t

Opaque draw3d context handle.

Each context maintains its own batch buffers, transform stack, and draw state.

Macros

MK_DRAW3D_CTX_INVALIDdefine

MK_DRAW3D_CTX_INVALID

Invalid sentinel for draw3d ctx.