zpl-c/librg
Free🚀 Making multi-player gamedev simpler since 2017
FreeFree tier
About zpl-c/librg
librg is a lightweight, single-header C99 library that serves as a middleware for multi-player game networking. It handles entity tracking, owner tracking, area-of-interest management, and world replication, enabling efficient bandwidth usage by synchronizing entities only with players within a defined visibility radius. Designed to be cross-platform and network-library agnostic, it integrates with libraries like ENet, GameNetworkingSockets, yojimbo, SLikeNet, KCP, Raknet, WebSocket, and WebRTC.
Key Features
Single-header C99 implementation, easy to integrate
Entity tracking and owner tracking across worlds
Area of interest management with radius-based visibility
World replication for client-server synchronization
Support for 2D and 3D virtual worlds
Custom entity visibility methods and advanced querying
Events for entity-to-entity status changes
Networked LOD (Level of Detail) based on variable radius
Cross-platform compatibility (Windows, Linux, macOS, etc.)
Agnostic networking integration (ENet, WebRTC, Raknet, etc.)
Pros & Cons
Pros
- Significantly reduces bandwidth compared to broadcasting all entities to all players
- Lightweight and minimal dependencies – single-header C99 library
- Cross-platform and works with various networking backends
- Provides built-in area-of-interest and LOD support out of the box
- Open source with an active community and documentation
Cons
- Requires integration with a separate networking library (not a full solution)
- Limited to C99 – not directly usable from higher-level languages without bindings
- Not a full game engine; only handles networking synchronization
- Documentation examples primarily focus on ENet integration
Best For
Building dedicated game servers for multiplayer gamesReducing bandwidth in networked games via visibility cullingPrototyping multiplayer mechanics with minimal boilerplateImplementing world replication in custom game enginesEducational projects for learning networked game architecture
FAQ
What is librg?
librg is a lightweight, single-header C99 library that simplifies multi-player game networking by managing entity tracking, area-of-interest, and world replication.
What network libraries does librg support?
It is designed to work with any network library that can send/receive char* buffers with size and integer IDs. Supported libraries include ENet, GameNetworkingSockets, yojimbo, SLikeNet, KCP, Raknet, WebSocket, WebRTC, and any UDP/TCP-based library.
Is librg cross-platform?
Yes, it is written in pure C99 and is cross-platform, supporting major operating systems including Windows, Linux, and macOS.
How do I install librg?
librg is a single-header library. You can download the latest librg.h from the releases page, or use curl/wget to fetch it directly.
Is librg free to use?
Yes, librg is open source and free to use. The repository is hosted on GitHub under the zpl-c organization.