A minimal, beginner-friendly 2D graphics library for C.
SDL2 is a powerful foundation, but it asks you to manage renderers, surfaces, and event queues before you can draw a circle. Kitra sits on top of SDL2 and collapses that setup into a single header and a straightforward game loop, so a beginner can focus on building something instead of configuring something. It is not a game engine — there are no scenes, no entities, no editor — just a clean API for a window, input, and drawing.
A Kitra program looks like this:
#include <kitra/kitra.h>
int main(void)
{
if (KitraInit(KITRA_SUBSYSTEM_ALL) != KITRA_STATUS_OK)
return 1;
if (KitraCreateWindow(KitraDefaultWindowDesc()) != KITRA_STATUS_OK)
return 1;
while (KitraIsRunning())
{
KitraBeginFrame();
KitraClearBackground(KITRA_BLACK);
KitraEndFrame();
}
KitraQuit(); // cleans up window, renderer, and SDL
return 0;
}Tested on Linux and macOS. Windows support is experimental — MSVC has stricter C compliance requirements that may require source changes.
The easiest way. One command installs SDL2 dependencies, downloads the latest release, and sets everything up automatically.
curl -sSL https://github.com/UniquePython/kitra/releases/latest/download/install.sh | bashDownload the prebuilt tarball for your platform from the releases page. Then install SDL2 dependencies manually:
# Ubuntu/Debian
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-gfx-dev libsdl2-ttf-dev libsdl2-mixer-dev
# Arch
sudo pacman -S sdl2 sdl2_image sdl2_gfx sdl2_ttf sdl2_mixer
# Fedora
sudo dnf install SDL2-devel SDL2_image-devel SDL2_gfx-devel SDL2_ttf-devel SDL2_mixer-devel
# macOS
brew install sdl2 sdl2_image sdl2_gfx sdl2_ttf sdl2_mixerThen extract and copy the files:
tar -xzf kitra-linux-x86_64.tar.gz
sudo cp -r kitra/include/kitra /usr/local/include/
sudo cp kitra/lib/libkitra.a /usr/local/lib/# Install SDL2 dependencies first (see Method 2 above)
git clone https://github.com/UniquePython/kitra.git
cd kitra
cmake -B build
cmake --build build -j$(nproc)
sudo cmake --install buildCMake:
find_package(Kitra REQUIRED)
target_link_libraries(your_target PRIVATE Kitra::Kitra)Makefile / manual:
CFLAGS += $(shell pkg-config --cflags kitra)
LIBS += $(shell pkg-config --libs kitra)Raw gcc:
# Linux
gcc main.c $(pkg-config --cflags --libs kitra) -Wl,--allow-shlib-undefined -o myapp
# macOS
gcc main.c $(pkg-config --cflags --libs kitra) -o myappThen include the header:
#include <kitra/kitra.h>| Module | Header | Description |
|---|---|---|
| Subsystem | kitra/kitra_subsystem.h |
Initialize and shut down Kitra; supports VIDEO, AUDIO, EVENTS, or KITRA_SUBSYSTEM_ALL flags with rollback safety on failure |
| Window | kitra/kitra_window.h |
Create and destroy the window with configurable flags (resizable, fullscreen, borderless, hidden); query size and per-frame resize events; access raw SDL window and renderer handles |
| Loop | kitra/kitra_loop.h |
Main loop control — KitraBeginFrame processes events, updates input; KitraEndFrame caps FPS, and presents the frame |
| Input | kitra/kitra_input.h |
Keyboard (down, pressed, released) and mouse (position, per-frame delta, scroll wheel, button down/pressed/released) queries |
| Drawing | kitra/kitra_draw.h |
Points, plain and thick lines, filled and outlined circles, ellipses, triangles, polygons, and rectangles (plain and rounded); blend mode control |
| Color | kitra/kitra_color.h |
Color construction via RGBA/HSV; lerp, fade, brighten, darken, invert, equality test, and pack/unpack to uint32_t |
| Textures | kitra/kitra_texture.h |
Load images (PNG, JPG, WebP, TIFF); draw at natural size or with source/destination rects, rotation, pivot, and flip; set tint, alpha, and blend mode; save screenshots; access raw SDL texture handle |
| Surfaces | kitra/kitra_surface.h |
CPU-side pixel buffers — create, load, read, write, and convert to texture |
| Audio | kitra/kitra_audio.h |
Load and play WAV sound effects; load and stream music tracks with loop, pause, resume, stop, and per-source volume control |
| Text & Fonts | kitra/kitra_text.h |
Load TTF fonts; draw plain, point-positioned, and printf-formatted text; pre-rasterize strings into cached textures; measure text dimensions |
| Timers | kitra/kitra_timer.h |
Per-frame delta time, smoothed FPS, target FPS cap, and general-purpose one-shot or repeating timers |
| RNG | kitra/kitra_rng.h |
PCG32 PRNG with per-instance (KitraRng) and global (KitraRand*) APIs; integers, bounded uints, floats, ranges, random points, unit directions, and probability checks |
| Math | kitra/kitra_math.h |
2D integer and float vectors (add, subtract, scale, dot, cross, normalize, rotate, lerp, angle); signed distance functions for points, rects, circles, and ellipses; quadratic, sine, and back easing curves |
| Types | kitra/kitra_types.h |
Core data structures — KitraVec2i, KitraVec2f, KitraPoint, KitraSize, KitraRect, KitraCircle, KitraEllipse, KitraColor, KitraBlendMode; included transitively via kitra.h |
| Error & Logging | kitra/kitra_error.h |
Log callback registration, last-error and severity retrieval, KitraClearError; default callback prints colored output to stdout/stderr; KITRA_LOG macro for internal use |
The examples/ directory contains Pong, Snake and Pendulum built with Kitra.
Kitra is licensed under the MIT License.
Kitra was heavily inspired by raylib and its philosophy of making graphics programming simple and accessible.



