Linux
Download the SDK bundle for linux-amd64 and put main.c beside the
folders it unzipped:
my_game/
├── include/
│ └── natiny.h
├── lib/
│ └── libnatiny_linux_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 main.o lib/libnatiny_linux_amd64.a -o app \
-lGL -lX11 -ldl -lpthread -lm
./app
A dark window opens with a green square in it. gcc works just as well;
nothing on that line is clang-specific.
libnatiny_linux_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.
The five libraries on the link line are the system's. You need their
development packages to build - on Debian and Ubuntu that is
libgl1-mesa-dev and libx11-dev - but not to run.
One archive carries both backends this platform can run, Vulkan and OpenGL.
NATINY_BACKEND_AUTO picks Vulkan; pass NATINY_BACKEND_OPENGL to choose the
other. Vulkan is opened at run time rather than imported, so a machine with no
Vulkan driver still starts and still runs OpenGL.
The SDK README in the bundle has the same commands for arm64 and i386, and
for linking libnatiny_linux_amd64.so instead of the archive.