mk_axesfunction
void mk_axes(float length)Draw axes at origin.
| Parameter | Type | Description |
|---|---|---|
length | float | Value for length. |
#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:
mk_axesfunctionvoid mk_axes(float length)Draw axes at origin.
| Parameter | Type | Description |
|---|---|---|
length | float | Value for length. |
mk_axes_atfunctionvoid mk_axes_at(mk_vec3 pos, float length)Draw axes at position.
| Parameter | Type | Description |
|---|---|---|
pos | mk_vec3 | Value for pos. |
length | float | Value for length. |
mk_boxfunctionvoid mk_box(mk_vec3 pos, mk_vec3 size, uint32_t color)Draw box at position.
| Parameter | Type | Description |
|---|---|---|
pos | mk_vec3 | Value for pos. |
size | mk_vec3 | Size in bytes. |
color | uint32_t | Value for color. |
mk_box_rotfunctionvoid mk_box_rot(mk_vec3 pos, mk_vec3 size, mk_vec3 rot, uint32_t color)Draw box with rotation (euler radians).
| Parameter | Type | Description |
|---|---|---|
pos | mk_vec3 | Value for pos. |
size | mk_vec3 | Size in bytes. |
rot | mk_vec3 | Value for rot. |
color | uint32_t | Value for color. |
mk_cam_clipfunctionvoid mk_cam_clip(float near, float far)Set camera clip planes.
| Parameter | Type | Description |
|---|---|---|
near | float | Value for near. |
far | float | Value for far. |
mk_cam_fovfunctionvoid mk_cam_fov(float degrees)Set camera field of view (degrees).
| Parameter | Type | Description |
|---|---|---|
degrees | float | Value for degrees. |
mk_cam_getfunctionmk_camera * mk_cam_get(void)Get internal camera for advanced use.
Returns A borrowed pointer, or NULL when unavailable.
mk_cam_lookatfunctionvoid mk_cam_lookat(mk_vec3 eye, mk_vec3 target)Set camera position and target.
| Parameter | Type | Description |
|---|---|---|
eye | mk_vec3 | Value for eye. |
target | mk_vec3 | Value for target. |
mk_cam_lookat_upfunctionvoid mk_cam_lookat_up(mk_vec3 eye, mk_vec3 target, mk_vec3 up)Set camera with up vector.
| Parameter | Type | Description |
|---|---|---|
eye | mk_vec3 | Value for eye. |
target | mk_vec3 | Value for target. |
up | mk_vec3 | Value for up. |
mk_cam_orbitfunctionvoid mk_cam_orbit(float distance, float yaw, float pitch)Orbit camera around origin.
| Parameter | Type | Description |
|---|---|---|
distance | float | Value for distance. |
yaw | float | Value for yaw. |
pitch | float | Value for pitch. |
mk_cam_setfunctionvoid mk_cam_set(const mk_camera *cam)Set custom camera.
| Parameter | Type | Description |
|---|---|---|
cam | const mk_camera * | Value for cam. |
mk_clearfunctionvoid mk_clear(uint32_t color)Clear screen with color (0xRRGGBBAA).
| Parameter | Type | Description |
|---|---|---|
color | uint32_t | Value for color. |
mk_conefunctionvoid mk_cone(mk_vec3 pos, float radius, float height, uint32_t color)Draw cone at position.
| Parameter | Type | Description |
|---|---|---|
pos | mk_vec3 | Value for pos. |
radius | float | Value for radius. |
height | float | Value for height. |
color | uint32_t | Value for color. |
mk_cubefunctionvoid mk_cube(mk_vec3 pos, float size, uint32_t color)Draw cube at position.
| Parameter | Type | Description |
|---|---|---|
pos | mk_vec3 | Value for pos. |
size | float | Size in bytes. |
color | uint32_t | Value for color. |
mk_cube_rotfunctionvoid mk_cube_rot(mk_vec3 pos, float size, mk_vec3 rot, uint32_t color)Draw cube with rotation (euler radians).
| Parameter | Type | Description |
|---|---|---|
pos | mk_vec3 | Value for pos. |
size | float | Size in bytes. |
rot | mk_vec3 | Value for rot. |
color | uint32_t | Value for color. |
mk_cylinderfunctionvoid mk_cylinder(mk_vec3 pos, float radius, float height, uint32_t color)Draw cylinder at position.
| Parameter | Type | Description |
|---|---|---|
pos | mk_vec3 | Value for pos. |
radius | float | Value for radius. |
height | float | Value for height. |
color | uint32_t | Value for color. |
mk_draw3d_aabbfunctionvoid 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).
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
min_x | float | Minimum corner |
min_y | float | Minimum corner |
min_z | float | Minimum corner |
max_x | float | Maximum corner |
max_y | float | Maximum corner |
max_z | float | Maximum corner |
color | uint32_t | RGBA color |
mk_draw3d_arcfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
cx | float | Center position |
cy | float | Center position |
cz | float | Center position |
radius | float | Arc radius |
nx | float | Normal direction |
ny | float | Normal direction |
nz | float | Normal direction |
start_angle | float | Start angle in radians |
end_angle | float | End angle in radians |
color | uint32_t | RGBA color |
segments | int | Number of segments (0 = auto) |
mk_draw3d_arrowfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
x1 | float | Start point |
y1 | float | Start point |
z1 | float | Start point |
x2 | float | End point (arrow tip) |
y2 | float | End point (arrow tip) |
z2 | float | End point (arrow tip) |
head_size | float | Arrow head size (0 = auto, based on length) |
color | uint32_t | RGBA color |
mk_draw3d_axesfunctionvoid mk_draw3d_axes(mk_draw3d_ctx_t ctx, float length)Draw coordinate axes at origin.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
length | float | Length of each axis |
mk_draw3d_beginfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
encoder | mk_encoder_t | Encoder from mk_encoder_begin() |
view | mk_view_id_t | View ID to draw to |
view_mtx | const float * | 4x4 view matrix (column-major) |
proj_mtx | const float * | 4x4 projection matrix (column-major) |
mk_draw3d_bezierfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
p0 | const float * | Start point (float3) |
p1 | const float * | Control point 1 (float3) |
p2 | const float * | Control point 2 (float3) |
p3 | const float * | End point (float3) |
color | uint32_t | RGBA color |
segments | int | Number of segments (0 = auto) |
mk_draw3d_billboardfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
x | float | World position |
y | float | World position |
z | float | World position |
width | float | Size in world units |
height | float | Size in world units |
texture | mk_texture_t | Sprite texture |
tint | uint32_t | Tint color (0xFFFFFFFF for no tint) |
mk_draw3d_billboard_quadfunctionvoid 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).
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
x | float | World position |
y | float | World position |
z | float | World position |
width | float | Size in world units |
height | float | Size in world units |
color | uint32_t | RGBA color |
mk_draw3d_billboard_uvfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
x | float | World position |
y | float | World position |
z | float | World position |
width | float | Size in world units |
height | float | Size in world units |
texture | mk_texture_t | Sprite texture |
u0 | float | UV coordinates (0-1) |
v0 | float | UV coordinates (0-1) |
u1 | float | UV coordinates (0-1) |
v1 | float | UV coordinates (0-1) |
tint | uint32_t | Tint color |
mk_draw3d_bounding_spherefunctionvoid 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).
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
cx | float | Center |
cy | float | Center |
cz | float | Center |
radius | float | Radius |
color | uint32_t | RGBA color |
rings | int | Number of rings (0 = auto, typically 3) |
mk_draw3d_boxfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
w | float | Width (X axis) |
h | float | Height (Y axis) |
d | float | Depth (Z axis) |
color | uint32_t | RGBA color (0xRRGGBBAA) |
mk_draw3d_capsulefunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
radius | float | Radius of cylinder and caps |
height | float | Total height (including caps) |
color | uint32_t | RGBA color (0xRRGGBBAA) |
segments | int | Number of radial segments, 0 = auto |
mk_draw3d_catmull_romfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
points | const float * | Array of float3 control points |
point_count | int | Number of control points (minimum 4) |
color | uint32_t | RGBA color |
segments_per_curve | int | Segments between each pair of control points |
mk_draw3d_circlefunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
cx | float | Center position |
cy | float | Center position |
cz | float | Center position |
radius | float | Circle radius |
nx | float | Normal direction (determines orientation) |
ny | float | Normal direction (determines orientation) |
nz | float | Normal direction (determines orientation) |
color | uint32_t | RGBA color |
segments | int | Number of segments (0 = auto) |
mk_draw3d_conefunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
radius | float | Base radius |
height | float | Cone height |
color | uint32_t | RGBA color (0xRRGGBBAA) |
segments | int | Number of radial segments, 0 = auto |
mk_draw3d_crossfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
x | float | Position |
y | float | Position |
z | float | Position |
size | float | Size of the cross arms |
color | uint32_t | RGBA color |
mk_draw3d_ctx_createfunctionmk_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_destroyfunctionvoid mk_draw3d_ctx_destroy(mk_draw3d_ctx_t ctx)Destroy a draw3d context.
Context must not be in draw mode.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Active operation context. |
mk_draw3d_cubefunctionvoid mk_draw3d_cube(mk_draw3d_ctx_t ctx, float size, uint32_t color)Draw a cube centered at origin.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
size | float | Side length |
color | uint32_t | RGBA color (0xRRGGBBAA) |
mk_draw3d_cylinderfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
radius | float | Cylinder radius |
height | float | Cylinder height |
color | uint32_t | RGBA color (0xRRGGBBAA) |
segments | int | Number of radial segments, 0 = auto |
mk_draw3d_default_ctxfunctionmk_draw3d_ctx_t mk_draw3d_default_ctx(void)Get default draw3d context (auto-created).
Returns The resulting handle or value.
mk_draw3d_default_viewfunctionmk_view_id_t mk_draw3d_default_view(void)Get default 3D view ID.
Returns The resulting handle or value.
mk_draw3d_discfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
cx | float | Center position |
cy | float | Center position |
cz | float | Center position |
radius | float | Disc radius |
nx | float | Normal direction |
ny | float | Normal direction |
nz | float | Normal direction |
color | uint32_t | RGBA color |
segments | int | Number of segments (0 = auto) |
mk_draw3d_endfunctionvoid mk_draw3d_end(mk_draw3d_ctx_t ctx)End 3D drawing mode and flush all batched draws.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Active operation context. |
mk_draw3d_flushfunctionvoid mk_draw3d_flush(void)Flush pending simple API draws (called automatically at frame end).
mk_draw3d_frustumfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
inv_view_proj | const float * | Inverse of view*projection matrix |
color | uint32_t | RGBA color |
mk_draw3d_gizmo_rotatefunctionvoid mk_draw3d_gizmo_rotate(mk_draw3d_ctx_t ctx, float x, float y, float z, float size)Draw a rotation gizmo (3 circles).
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
x | float | Position |
y | float | Position |
z | float | Position |
size | float | Gizmo size |
mk_draw3d_gizmo_scalefunctionvoid 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).
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
x | float | Position |
y | float | Position |
z | float | Position |
size | float | Gizmo size |
mk_draw3d_gizmo_translatefunctionvoid mk_draw3d_gizmo_translate(mk_draw3d_ctx_t ctx, float x, float y, float z, float size)Draw a translation gizmo (3 arrows).
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
x | float | Position |
y | float | Position |
z | float | Position |
size | float | Gizmo size |
mk_draw3d_gridfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
size | float | Total size of grid (side length) |
divisions | int | Number of divisions per axis |
color | uint32_t | RGBA color (0xRRGGBBAA) |
mk_draw3d_initfunctionbool mk_draw3d_init(void)Initialize shared 3D drawing resources (called automatically on first use).
Returns true on success
mk_draw3d_light_directionalfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
x | float | Gizmo position |
y | float | Gizmo position |
z | float | Gizmo position |
dx | float | Light direction |
dy | float | Light direction |
dz | float | Light direction |
size | float | Gizmo size |
color | uint32_t | Light color |
mk_draw3d_light_pointfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
x | float | Light position |
y | float | Light position |
z | float | Light position |
radius | float | Light radius |
color | uint32_t | Light color |
mk_draw3d_light_spotfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
x | float | Light position |
y | float | Light position |
z | float | Light position |
dx | float | Light direction |
dy | float | Light direction |
dz | float | Light direction |
range | float | Light range |
inner_angle | float | Inner cone angle (radians) |
outer_angle | float | Outer cone angle (radians) |
color | uint32_t | Light color |
mk_draw3d_linefunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
x1 | float | Start point |
y1 | float | Start point |
z1 | float | Start point |
x2 | float | End point |
y2 | float | End point |
z2 | float | End point |
color | uint32_t | RGBA color (0xRRGGBBAA) |
mk_draw3d_obbfunctionvoid 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).
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
center | const float * | 3-element center position |
half_extents | const float * | 3-element half sizes |
rotation | const float * | 4x4 rotation matrix (or full transform) |
color | uint32_t | RGBA color |
mk_draw3d_planefunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
width | float | Width (X axis) |
depth | float | Depth (Z axis) |
color | uint32_t | RGBA color (0xRRGGBBAA) |
mk_draw3d_pointfunctionvoid 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).
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
x | float | Position |
y | float | Position |
z | float | Position |
size | float | Point size in world units |
color | uint32_t | RGBA color |
mk_draw3d_polylinefunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
points | const float * | Array of float3 positions (x,y,z,x,y,z,...) |
point_count | int | Number of points |
color | uint32_t | RGBA color |
closed | bool | true to connect last point to first |
mk_draw3d_polyline_coloredfunctionvoid 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).
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
points | const float * | Array of float3 positions |
colors | const uint32_t * | Array of RGBA colors (one per point) |
point_count | int | Number of points |
closed | bool | true to connect last to first |
mk_draw3d_pop_transformfunctionvoid mk_draw3d_pop_transform(mk_draw3d_ctx_t ctx)Pop transform from stack.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
mk_draw3d_prepare_viewfunctionbool 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.
| Parameter | Type | Description |
|---|---|---|
view | mk_view_id_t | Value for view. |
view_mtx | const float * | Value for view mtx. |
proj_mtx | const float * | Value for proj mtx. |
Returns True when the operation succeeds.
mk_draw3d_push_transformfunctionvoid mk_draw3d_push_transform(mk_draw3d_ctx_t ctx, const float *mtx)Push current transform onto stack and set new transform.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
mtx | const float * | 4x4 model matrix (column-major), NULL for identity |
mk_draw3d_rayfunctionvoid 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).
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
ox | float | Origin point |
oy | float | Origin point |
oz | float | Origin point |
dx | float | Direction (normalized) |
dy | float | Direction (normalized) |
dz | float | Direction (normalized) |
length | float | Ray length |
color | uint32_t | RGBA color |
mk_draw3d_set_billboard_modefunctionvoid mk_draw3d_set_billboard_mode(mk_draw3d_ctx_t ctx, mk_billboard_mode mode)Set billboard mode for subsequent sprite draws.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
mode | mk_billboard_mode | Billboard mode |
mk_draw3d_set_transformfunctionvoid mk_draw3d_set_transform(mk_draw3d_ctx_t ctx, const float *mtx)Set model transform for subsequent primitives.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
mtx | const float * | 4x4 model matrix (column-major), NULL for identity |
mk_draw3d_shutdownfunctionvoid mk_draw3d_shutdown(void)Shutdown shared 3D drawing resources (call at program exit).
mk_draw3d_spherefunctionvoid mk_draw3d_sphere(mk_draw3d_ctx_t ctx, float radius, uint32_t color, int segments)Draw a UV sphere centered at origin.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
radius | float | Sphere radius |
color | uint32_t | RGBA color (0xRRGGBBAA) |
segments | int | Number of segments (latitude and longitude), 0 = auto |
mk_draw3d_textfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
x | float | World position |
y | float | World position |
z | float | World position |
text | const char * | Text string |
color | uint32_t | RGBA color |
scale | float | Text scale (1.0 = default size) |
mk_draw3d_textffunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
x | float | World position |
y | float | World position |
z | float | World position |
color | uint32_t | RGBA color |
scale | float | Text scale |
fmt | const char * | Format string |
| ... | โ |
mk_draw3d_torusfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
major_r | float | Major radius (center to tube center) |
minor_r | float | Minor radius (tube radius) |
color | uint32_t | RGBA color (0xRRGGBBAA) |
major_seg | int | Major segments (around the ring), 0 = auto |
minor_seg | int | Minor segments (around the tube), 0 = auto |
mk_draw3d_vectorfunctionvoid 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.
| Parameter | Type | Description |
|---|---|---|
ctx | mk_draw3d_ctx_t | Context handle |
px | float | Origin point |
py | float | Origin point |
pz | float | Origin point |
dx | float | Direction (will be normalized) |
dy | float | Direction (will be normalized) |
dz | float | Direction (will be normalized) |
length | float | Length of the arrow |
color | uint32_t | RGBA color |
mk_dtfunctionfloat mk_dt(void)Get delta time since last frame (seconds).
Returns The resulting value.
mk_gridfunctionvoid mk_grid(int divisions, float spacing)Draw grid in XZ plane.
| Parameter | Type | Description |
|---|---|---|
divisions | int | Value for divisions. |
spacing | float | Value for spacing. |
mk_grid_colorfunctionvoid mk_grid_color(int divisions, float spacing, uint32_t color)Draw grid with color.
| Parameter | Type | Description |
|---|---|---|
divisions | int | Value for divisions. |
spacing | float | Value for spacing. |
color | uint32_t | Value for color. |
mk_linefunctionvoid mk_line(mk_vec3 start, mk_vec3 end, uint32_t color)Draw 3D line.
| Parameter | Type | Description |
|---|---|---|
start | mk_vec3 | Value for start. |
end | mk_vec3 | Value for end. |
color | uint32_t | Value for color. |
mk_planefunctionvoid mk_plane(mk_vec3 pos, float width, float depth, uint32_t color)Draw plane at position.
| Parameter | Type | Description |
|---|---|---|
pos | mk_vec3 | Value for pos. |
width | float | Value for width. |
depth | float | Value for depth. |
color | uint32_t | Value for color. |
mk_spherefunctionvoid mk_sphere(mk_vec3 pos, float radius, uint32_t color)Draw sphere at position.
| Parameter | Type | Description |
|---|---|---|
pos | mk_vec3 | Value for pos. |
radius | float | Value for radius. |
color | uint32_t | Value for color. |
mk_text3dfunctionvoid mk_text3d(mk_vec3 pos, const char *text, uint32_t color)Draw text label at 3D position (projects to screen).
| Parameter | Type | Description |
|---|---|---|
pos | mk_vec3 | Value for pos. |
text | const char * | Value for text. |
color | uint32_t | Value for color. |
mk_text3dffunctionvoid mk_text3df(mk_vec3 pos, uint32_t color, const char *fmt,...)Draw formatted text label at 3D position.
| Parameter | Type | Description |
|---|---|---|
pos | mk_vec3 | Value for pos. |
color | uint32_t | Value for color. |
fmt | const char * | Value for fmt. |
| ... | โ |
mk_timefunctionfloat mk_time(void)Get elapsed time since app start (seconds).
Returns The resulting value.
mk_billboard_modeenumBillboard mode for sprites.
| Value | Description |
|---|---|
MK_BILLBOARD_SCREEN | Always face screen (UI-like). |
MK_BILLBOARD_WORLD | Face camera but stay upright (Y-up). |
MK_BILLBOARD_AXIS | Rotate around specified axis. |
mk_billboard_modetypedeftypedef enum mk_billboard_mode mk_billboard_modeBillboard mode for sprites.
mk_draw3d_ctx_ttypedeftypedef struct mk_draw3d_ctx* mk_draw3d_ctx_tOpaque draw3d context handle.
Each context maintains its own batch buffers, transform stack, and draw state.
MK_DRAW3D_CTX_INVALIDdefineMK_DRAW3D_CTX_INVALIDInvalid sentinel for draw3d ctx.