Render passes
Every draw call in modkit belongs to a pass. A pass owns a render target, a clear state and a view/projection pair, and bgfx sorts submissions by the pass’s view id.
The implicit pass
Section titled “The implicit pass”For simple cases there is nothing to set up. mk_clear opens the default pass against
the backbuffer:
static void frame(void* user_data) { (void)user_data; mk_clear(MK_RGBA(0x11, 0x11, 0x14, 0xff)); mk_draw3d_cube((mk_vec3){0, 0, 0}, 1.0f, MK_RGBA(0x5f, 0x6f, 0xd8, 0xff));}Explicit passes
Section titled “Explicit passes”Once you have more than one target — a shadow map, an offscreen buffer, a post chain — open passes yourself:
mk_pass_desc desc = { .target = shadow_target, .clear_flags = MK_CLEAR_DEPTH, .view = light_view, .projection = light_proj,};
mk_pass_t pass = mk_pass_begin(&desc); draw_scene_geometry();mk_pass_end(pass);Passes are submitted in the order they are begun. Anything drawn between begin and
end belongs to that pass, and resource creation is main-thread-only — see
pass.h for the full surface.
The same thing from TypeScript
Section titled “The same thing from TypeScript”const pass = runtime.beginPass({ clearColor: '#111114' });pass.draw({ geometry, material, position: [0, 0, 0] });runtime.finishPass(pass);The JS binding mirrors the C model rather than inventing its own, so a pass means the same thing in both. See the JavaScript guides for demos that run on the page.