# raylib — A Simple C Library to Enjoy Video Game Programming > raylib is an education-focused C game library designed for learning, with a clean API that feels closer to SDL than to Unity. 500+ examples, zero external dependencies, bindings for 60+ languages. ## Install Save in your project root: # raylib — Simple C Library for Game Programming ## Quick Use ```c // main.c — complete game window #include "raylib.h" int main(void) { InitWindow(800, 450, "raylib example"); SetTargetFPS(60); while (!WindowShouldClose()) { BeginDrawing(); ClearBackground(RAYWHITE); DrawText("Congrats! You created your first window.", 190, 200, 20, LIGHTGRAY); EndDrawing(); } CloseWindow(); return 0; } ``` ```bash # Compile and run cc main.c -o game -lraylib -lm -ldl -lpthread ./game ``` ## Introduction raylib, created by Ramon Santamaria (raysan5), is the C library for people who want to make games the old-fashioned way — no scripting, no editor, no bloat. Its API is deliberately simple: 500+ functions with obvious names, 500+ examples, and a single-header optional build. If you've programmed in C, you can make a game in an afternoon. With over 32,000 GitHub stars, raylib is the #1 go-to library for game programming courses, game jams, and hobbyist game projects. It supports 2D, 3D, audio, shaders, splines, and includes bindings for Python, Rust, Go, Zig, Odin, Nim, and 50+ other languages. ## What raylib Does raylib gives you `InitWindow`, `BeginDrawing`, `DrawText`, `DrawTexture`, `LoadSound`, `GetKeyPressed` — everything a game needs, in a flat C API. Under the hood it uses OpenGL (or WebGL/ES), GLFW, and custom audio mixing. Modules cover core/input/drawing (rcore), 2D textures + 3D models + meshes (rlgl), audio (raudio), physics (raymath + custom), and more. ## Architecture Overview ``` raylib | +-+-------+--------+-------+--------+ | | | | | core shapes text textures models (rcore) (rshapes)(rtext) (rtextures)(rmodels) | audio (raudio) — miniaudio under the hood | math + splines + physics helpers (raymath, rlgl) | Platform layer Desktop: GLFW + OpenGL 2.1/3.3/4.3/ES2 Web: emscripten + WebGL Android + iOS via bindings Raspberry Pi / DRM direct ``` ## Self-Hosting & Configuration ```c // 3D example — camera + cube #include "raylib.h" int main(void) { InitWindow(800, 450, "3D"); Camera camera = {0}; camera.position = (Vector3){0, 4, 6}; camera.target = (Vector3){0, 0, 0}; camera.up = (Vector3){0, 1, 0}; camera.fovy = 60.0f; camera.projection = CAMERA_PERSPECTIVE; SetTargetFPS(60); while (!WindowShouldClose()) { UpdateCamera(&camera, CAMERA_FREE); BeginDrawing(); ClearBackground(RAYWHITE); BeginMode3D(camera); DrawCube((Vector3){0,0,0}, 2, 2, 2, RED); DrawCubeWires((Vector3){0,0,0}, 2, 2, 2, MAROON); DrawGrid(10, 1); EndMode3D(); DrawFPS(10, 10); EndDrawing(); } CloseWindow(); } ``` ```bash # CMake build (recommended beyond one-file examples) mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release .. cmake --build . # Emscripten for WebAssembly emcc -o game.html main.c -Os -Wall \ $(pkg-config --cflags raylib) $(pkg-config --libs raylib) \ -s USE_GLFW=3 -s ASYNCIFY --preload-file assets ``` ## Key Features - **Simple C API** — 500+ functions, clear names, no abstractions - **2D + 3D + audio + shaders** — one library covers a full game - **500+ examples** — runnable demos for every feature - **Bindings everywhere** — Python (pyray), Rust, Go, Zig, Nim, Odin, 50+ more - **Cross-platform** — Windows, Linux, macOS, Web (WASM), Android, iOS, Pi - **No external deps** — GLFW + OpenGL included - **Education-focused** — designed for learning, not maximum features - **Commercial OK** — zlib license, no royalties ## Comparison with Similar Tools | Feature | raylib | SDL2 | SFML | LÖVE (Lua) | Godot | |---|---|---|---|---|---| | Language | C | C | C++ | Lua (scripted) | GDScript / C# / C++ | | Audio / image / input | Built-in | Yes | Yes | Yes | Yes | | 3D | Yes | Via GL calls | Limited | Via 3rd party | Yes (engine) | | Editor | No | No | No | No | Yes | | Curve | Shallow | Moderate | Moderate | Shallow | Moderate | | Best For | Learning + jam-sized games | Serious game dev | C++ indie games | Lua enthusiasts | Full-featured engine | ## FAQ **Q: raylib vs SDL?** A: SDL is lower-level (input + window + raw rendering). raylib is a layer above SDL-tier primitives with higher-level game helpers. For pure engine work, SDL + your own abstractions; for quick games, raylib wins. **Q: Can I make a real game with raylib?** A: Yes — plenty of shipped indie games use raylib. For AAA ambitions, you'd outgrow it; for jam games, retro-inspired titles, or teaching-focused projects, it's perfect. **Q: Which language binding is best?** A: Python (pyray) for scripting + ease. Rust (raylib-rs) for type safety. Go (raylib-go), Zig (raylib-zig) are active. For production C, just use the C API directly. **Q: How does it compare to Godot?** A: Godot is a full engine with editor + scripting + scene tree. raylib is a library — you write your own game structure in C. Godot is easier for larger games; raylib gives full control. ## Sources - GitHub: https://github.com/raysan5/raylib - Website: https://www.raylib.com - Author: Ramon Santamaria - License: zlib --- Source: https://tokrepo.com/en/workflows/a83e3bc5-3862-11f1-9bc6-00163e2b0d79 Author: AI Open Source