floooh/sokol
Freeminimal cross-platform standalone C headers
FreeFree tier
About floooh/sokol
Sokol is a collection of minimal, cross-platform, single-file C and C++ headers that provide simple abstractions for graphics, audio, input, and other system-level tasks. Inspired by the STB style, it wraps multiple backends (OpenGL, Metal, D3D11, WebGPU, etc.) into a unified API, making it easy to write portable real-time applications such as games and demos. Core libraries include sokol_gfx.h for 3D rendering, sokol_app.h for window and input handling, sokol_audio.h for audio playback, sokol_time.h for time measurement, and more. Utility add‑ons provide Dear ImGui/Nuklear backends, debug text rendering, and simple shape generation.
Key Features
Single-file C/C++ headers with no external dependencies (STB style)
Unified 3D graphics API sokol_gfx.h (OpenGL / GLES3 / WebGL2, Metal, D3D11, WebGPU)
App framework sokol_app.h (window creation, input, 3D context setup) with cross-platform support
Minimal buffer-streaming audio playback via sokol_audio.h
Asynchronous data streaming from HTTP and local filesystem (sokol_fetch.h)
Unified command-line / URL argument parser (sokol_args.h)
Standard logging callback (sokol_log.h)
Utility libraries for Dear ImGui, Nuklear, fontstash, debug text, shape generation, and more
Pros & Cons
Pros
- Minimal and easy to integrate – just drop a header into your project
- Cross-platform: supports Windows, macOS, Linux, iOS, Android, and Web via WASM
- Performance-oriented with low overhead and no unnecessary abstractions
- Well-documented source code with concise API comments and examples
- Active community with numerous sample projects and games
Cons
- Low-level nature may require understanding of graphics concepts and underlying APIs
- Documentation beyond the headers is spread across examples and blog posts
- Limited to 3D graphics features; no built-in GUI or advanced asset pipeline
Best For
Game development with portable C or C++ codeReal-time graphics demos and interactive visualizationsBuilding cross-platform desktop applications with OpenGL/Metal/D3D backendsWebAssembly (WASM) porting of existing C/C++ projectsEmbedded systems or retro-style emulator projects
FAQ
What graphics backends does sokol_gfx.h support?
sokol_gfx.h wraps OpenGL, GLES3/WebGL2, Metal, D3D11, and WebGPU, allowing the same API to run across desktop, mobile, and web.
Is Sokol available under a permissive license?
Yes, the Sokol headers are released under the MIT license as indicated in the repository's LICENSE file.
Can I use Sokol with C++?
Yes, the headers are written in C but are designed to be used from both C and C++ projects without modification.