Windows
Download the SDK bundle for windows-amd64 and put main.c beside the
folders it unzipped:
my_game/
├── include/
│ └── natiny.h
├── lib/
│ └── libnatiny_windows_amd64.a
└── main.c
#include "natiny.h"
#include <stddef.h>
static NatinyWindow window;
static void frame(float dt, void* userdata)
{
(void)dt;
(void)userdata;
natiny_window_bind(window);
natiny_render_clear(0.07f, 0.09f, 0.13f, 1.0f);
natiny_render_set_color(0.66f, 0.76f, 0.22f, 1.0f);
natiny_render_rectangle(360.0f, 260.0f, 80.0f, 80.0f);
natiny_window_unbind();
}
int main(void)
{
if (!natiny_backend_init(NATINY_BACKEND_AUTO)) {
return 1;
}
window = natiny_window_create("Hello, Natiny", 800, 600);
if (!window) {
natiny_backend_shutdown();
return 1;
}
natiny_backend_loop(frame, NULL);
natiny_backend_shutdown();
return 0;
}
Compile and link:
clang -O2 -Iinclude -c main.c -o main.o
clang -O2 -static main.o lib/libnatiny_windows_amd64.a -o app.exe \
-ld3d12 -ldxgi -ld3dcompiler -ldxguid -lopengl32 \
-lgdi32 -luser32 -lshell32 -ldwmapi -lpthread
app.exe
A dark window opens with a green square in it.
libnatiny_windows_amd64.a is the whole engine - GLFW, the shader compiler,
the mixer and the physics solver are already inside it, so there is nothing
else of Natiny's to link. It is plain C with no C++ runtime anywhere, so a C
compiler is all you need.
Keep -static. Without it the executable imports libwinpthread-1.dll
out of your toolchain and will not start on a machine that has no toolchain
installed. Everything else on that line is part of Windows.
One archive carries every backend this platform can run - Direct3D 12, Vulkan
and OpenGL. NATINY_BACKEND_AUTO picks Direct3D 12; pass
NATINY_BACKEND_VULKAN or NATINY_BACKEND_OPENGL to choose. Vulkan is opened
at run time rather than imported, so a machine with no Vulkan driver still
starts and still runs the other two.
The SDK README in the bundle has the same commands for arm64 and i386, and
for linking natiny_windows_amd64.dll instead of the archive.