natiny_backend_init
int natiny_backend_init(int backend);
Chooses the graphics backend and prepares the engine to draw with it. Call it before APIs that require an initialized engine. Returns 0 when this build cannot run what was asked for, after printing what it does have.
| constant | platforms |
|---|---|
NATINY_BACKEND_AUTO |
the platform's first choice |
NATINY_BACKEND_D3D12 |
Windows |
NATINY_BACKEND_VULKAN |
Windows, Linux |
NATINY_BACKEND_OPENGL |
Windows, Linux |
NATINY_BACKEND_METAL |
macOS |
NATINY_BACKEND_WEBGPU |
web |
The library carries every backend enabled for its platform; this call chooses which one to use.
Example
int main(void) {
if (!natiny_backend_init(NATINY_BACKEND_AUTO))
return 1;
printf("%s\n", natiny_backend_get_name(natiny_backend_get_current()));
// ... your code ...
natiny_backend_shutdown();
return 0;
}
Notes
- Must be called exactly once at startup.
- Asking for a backend this platform does not carry returns 0, and
natiny_window_create()then fails too.