natiny.window.bind
natiny.window.bind(win [, fn])
Binds a window as the render target until it is unbound or replaced. With a callback, the window is unbound after the callback returns.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
win |
number |
Window handle from natiny.window.create |
|
fn |
function |
nil |
Callback whose draws target this window |
Example
natiny.window.bind(win, function()
draw_frame()
end)
Notes
- Every bind resets the clear color, draw color, current texture, camera,
material and surface targets to defaults. Call
natiny.render.clearwhen the existing pixels should be replaced. - Binding over a different window ends its frame. The matching
natiny.window.unbindstarts a new frame for the previous window. - Binding or unbinding a window drops any open surface target sets and reports their count to standard error. Bind the window before its surfaces; see The bind stack.
- Rebinding the same window inside one
natiny.backend.loopcallback preserves its earlier draws. The accumulated image is presented after the callback. - In
SCALE_MODE_STRETCH, the off-screen canvas is copied to the window once when the engine frame is presented. - With
fn, Lua unbinds the window even if the callback raises an error, then propagates the error.