21 FEB 2026

rahulmnavneeth

api contracts

homedocs

Headers

HeaderContentsDocs
types.hValue types, math utilitiesMath
backend.hBackend enumeration and query functions
viewport.hViewport lifecycle, camera, rendering
scene.hMesh creation, removal, transforms, textures
picking.hObject picking via ID bufferPicking
light.hMulti-light system (directional, point, spot)Light
input.hInput events, output events, interactionInput
gizmo.hTRS manipulation gizmoGizmo
camera.hOrbit cameraCamera
camera_query.hCamera state snapshot, ray generationCamera Query
display.hDisplay settings and visualization modesDisplay
overlay.hBuilt-in and custom overlaysOverlay
material.hPBR-inspired material descriptorMaterial
vertex_format.hFlexible vertex attributesVertex Format
loader.hOBJ and binary mesh loadingLoader
query.hRead-only mesh introspectionQuery
snapshot.hZero-copy scene iterationSnapshot
spatial.hAABB, frustum culling, raycastingSpatial
undo.hTransform undo/redo stackUndo
pipeline.hCustom render pass hooksPipeline
particle.hParticle emitters and presetsParticle
water.hProcedural water surfaceWater
postprocess.hGamma, tonemapping, vignette, fogPost-Processing
config.hOptional Lua configurationConfig
log.hLogging levels and callbacksLog
profile.hFrame timing statisticsProfile
mop.hUmbrella header — includes all above

Viewport Lifecycle

mop_viewport_create

MopViewport *mop_viewport_create(const MopViewportDesc *desc);
Preconditiondesc non-NULL, width > 0, height > 0, valid backend
ReturnsValid pointer or NULL on failure
OwnershipCaller owns the pointer; must call mop_viewport_destroy
DefaultsCamera at (0,0,5), clear (0.1,0.1,0.1,1), solid mode

mop_viewport_destroy

void mop_viewport_destroy(MopViewport *viewport);
PreconditionNULL or valid viewport pointer
EffectDestroys all meshes, lights, gizmo, overlays, RHI resources, and the viewport
NULLNo-op

mop_viewport_resize

void mop_viewport_resize(MopViewport *viewport, int width, int height);
Preconditionwidth > 0, height > 0
EffectReallocates framebuffer, recomputes projection matrix

Camera

mop_viewport_set_camera

void mop_viewport_set_camera(MopViewport *viewport,
                             MopVec3 eye, MopVec3 target, MopVec3 up,
                             float fov_degrees,
                             float near_plane, float far_plane);
Preconditioneye != target, up not parallel to view direction
Preconditionfov_degrees in (0, 180), 0 < near < far
EffectRecomputes view and projection matrices immediately

Scene

mop_viewport_add_mesh

MopMesh *mop_viewport_add_mesh(MopViewport *viewport, const MopMeshDesc *desc);
PreconditionValid arrays, index_count % 3 == 0, indices in bounds
CopyVertex and index data are copied into RHI buffers
OwnershipViewport owns the mesh; app may free its arrays after
LimitMOP_MAX_MESHES (4096)

mop_viewport_add_mesh_ex

MopMesh *mop_viewport_add_mesh_ex(MopViewport *viewport, const MopMeshDescEx *desc);

Flexible vertex format variant. desc->vertex_format specifies attribute layout and stride. Otherwise identical to mop_viewport_add_mesh.

mop_mesh_set_transform

void mop_mesh_set_transform(MopMesh *mesh, const MopMat4 *transform);
EffectUpdates the mesh model matrix; takes effect on next render

mop_mesh_set_position / set_rotation / set_scale

void mop_mesh_set_position(MopMesh *mesh, MopVec3 position);
void mop_mesh_set_rotation(MopMesh *mesh, MopVec3 euler_radians);
void mop_mesh_set_scale(MopMesh *mesh, MopVec3 scale);

TRS convenience setters. The model matrix is recomputed from the TRS components on next render.

Lights

mop_viewport_add_light

MopLight *mop_viewport_add_light(MopViewport *viewport, const MopLight *desc);
ReturnsPointer to the light slot, or NULL if MOP_MAX_LIGHTS (8) reached
CopyThe descriptor is copied into the viewport's light array

mop_viewport_remove_light

void mop_viewport_remove_light(MopViewport *viewport, MopLight *light);

Marks the light inactive and destroys its indicator mesh.

Rendering

mop_viewport_render

void mop_viewport_render(MopViewport *viewport);
EffectClears buffers, updates indicators and gizmo, draws all passes, finalizes frame
SyncFully synchronous — returns only when all pixels are written

mop_viewport_read_color

const uint8_t *mop_viewport_read_color(MopViewport *viewport,
                                       int *out_width, int *out_height);
ReturnsPointer to RGBA8 data, row-major, top-left origin
LifetimeValid until next render, resize, or destroy
OwnershipBorrowed — caller must not free

Picking

mop_viewport_pick

MopPickResult mop_viewport_pick(MopViewport *viewport, int x, int y);
Returnshit=true with object_id and depth if a rendered object exists at (x,y)
DepthNormalized [0, 1] — 0 is near plane, 1 is far plane
TimingReads from the most recently rendered frame

Input / Events

mop_viewport_input

void mop_viewport_input(MopViewport *viewport, const MopInputEvent *event);

Feeds a platform input event into the viewport's interaction state machine. See Input for the full event type list and state machine.

mop_viewport_poll_event

bool mop_viewport_poll_event(MopViewport *viewport, MopEvent *out);

Dequeues the next output event. Returns false when the queue is empty. See Input for the full output event type list.