natiny.surface.get_texture
natiny.surface.get_texture(surf) -> texture
Returns the surface's color attachment as a texture handle.
The handle stays valid until the surface is destroyed - or until a resize, which replaces the attachment, after which this has to be asked again.
Parameters
| Name | Type | Description |
|---|---|---|
surf |
number |
Surface handle |
Returns
| Type | Description |
|---|---|
number |
Texture handle, or 0 if the surface is not valid |
Example
local texture = natiny.surface.get_texture(surface)
Notes
- The texture belongs to the surface: destroying it with
natiny.texture.destroywould leave the surface with nothing to draw into.natiny.surface.destroyfrees both attachments. - Reading a surface in the same pass that writes it is undefined; unbind it first.