natiny_surface_bind
void natiny_surface_bind(NatinySurface surf, uint32_t slot);
Makes the surface a render target. Bind it between natiny_window_bind and
natiny_window_unbind so drawing has an active frame command buffer. Multiple
surfaces can be bound to distinct slots for one pass.
Parameters
| Name | Type | Description |
|---|---|---|
surf |
NatinySurface |
Surface handle from natiny_surface_create |
slot |
uint32_t |
Target slot, 0 to NATINY_MAX_TARGETS - 1 |
Example
natiny_window_bind(win);
natiny_surface_bind(rt, 0);
draw_scene();
natiny_surface_unbind();
natiny_window_unbind();
Notes
- Call this function between
natiny_window_bindandnatiny_window_unbind. - Slot
0opens a target set and determines its size, 2D projection, and depth attachment. Other slots add colour targets to that set. All surfaces in a set must have identical dimensions. natiny_surface_unbindends the entire target set; individual slots cannot be unbound.- Binding slot
0suspends the current target state. The matching unbind restores it; see The bind stack. - A bind flushes the current batch and ends the current render pass.
- Surface binds may nest up to 64 stored levels. Deeper binds still take effect, but their previous state cannot be restored.
- Rebinding a surface preserves its color and depth contents. Call
natiny_render_clearexplicitly when they should be replaced. - A surface also preserves its contents across frames. Clear passes that redraw the complete image, including its depth buffer.
- A new target set starts with no camera. Bind the camera after slot
0so its projection uses the target's aspect ratio.