A minimal, efficient, cross-platform 2D graphics painter library in pure C, built on Sokol GFX.
Sokol GP is a lightweight 2D graphics rendering library written in pure C. It provides an optimized, batched drawing system for basic 2D primitives (rectangles, triangles, lines, points) using modern graphics APIs through Sokol GFX. It solves the problem of efficiently rendering 2D content without the complexity of low-level GPU programming.
C/C++ developers building 2D games, graphical applications, or UI toolkits who need a performant, cross-platform rendering layer without the overhead of larger engines.
Developers choose Sokol GP for its minimal API, automatic batching optimizer that significantly boosts performance, and seamless integration with Sokol GFX. Its 2D-specific design avoids unnecessary 3D overhead while providing modern graphics backend support.
Minimal modern efficient cross platform 2D graphics painter in C
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The batch optimizer reorders and merges draw commands up to a configurable depth, reducing GPU dispatches and boosting performance by up to 2.2x in benchmarks, as shown in the sample-bench.c example.
Leverages Sokol GFX for seamless support across D3D11, OpenGL 3.3+, Metal, and WebGPU, ensuring wide compatibility without manual backend coding.
Uses pre-allocated buffers for draw commands and vertices, eliminating memory management overhead in draw loops for predictable performance, as emphasized in the design choices.
Employs CPU-side transformations with 2x3 matrices and always-textured pipelines to minimize state changes, optimized solely for 2D rendering to avoid 3D overhead.
Requires setting up and managing Sokol GFX first, adding significant complexity and a steep learning curve for developers not already embedded in the Sokol ecosystem.
Pre-allocated command and vertex buffers can overflow if underestimated, forcing manual size tuning and error handling without dynamic resizing, as admitted in the error handling section.
The batch optimizer scans previous draw commands with O(n) CPU complexity, which can increase CPU usage at higher depths, a performance trade-off for reduced GPU calls that may not scale well for very high-frequency drawing.