natiny_surface_create
C
NatinySurface natiny_surface_create(uint32_t width, uint32_t height,
uint32_t format, bool depth);
Creates an off-screen render target: one colour texture, and a depth buffer
of its own unless it is asked for without one.
Parameters
| Name |
Type |
Description |
width |
uint32_t |
Surface width in pixels |
height |
uint32_t |
Surface height in pixels |
format |
uint32_t |
Pixel format of the colour texture |
depth |
bool |
Give it a depth buffer |
| Define |
Value |
Meaning |
NATINY_FORMAT_COLOR |
0 |
Window-compatible BGRA8 color format |
NATINY_FORMAT_RGBA8 |
1 |
Explicit RGBA8 channel order |
NATINY_FORMAT_RGBA16F |
2 |
half float - normals, positions, anything past 1 |
NATINY_FORMAT_RGBA32F |
3 |
full float |
NATINY_FORMAT_R32F |
4 |
one float channel, e.g. linear depth |
Returns
| Type |
Description |
NatinySurface |
Surface handle, or 0 on failure |
Example
C
NatinySurface scene = natiny_surface_create(
1280, 720, NATINY_FORMAT_COLOR, true);
Notes
- Requires an initialized graphics device and positive dimensions; failure
returns
0.
NATINY_FORMAT_COLOR matches the window-compatible BGRA8 layout;
NATINY_FORMAT_RGBA8 has explicit RGBA channel order. Floating-point formats
preserve values outside 0..1.
- The surface owns its color attachment and optional depth attachment.