bgfx
v2024.11Cross-platform rendering abstraction supporting 12+ graphics APIs from a single codebase
Development Activity
Sample Renders
Overview
Best for
Engine developers and tool creators who need a thin, portable GPU abstraction layer without opinionated scene management or material systems
Not ideal for
Developers who want a ready-to-use rendering engine with built-in materials, scene management, or beginner-friendly documentation
Strengths
- Unmatched backend coverage — a single C99 API compiles to 12+ graphics APIs including Vulkan, DirectX 9/11/12, Metal, OpenGL, WebGL, WebGPU, and console-specific backends (GNM, AGC, NVN)
- Extremely clean, minimal C99 API with zero unnecessary abstractions — the entire public API surface fits in a single well-commented header file
- Ships with shaderc, a powerful cross-platform shader compiler that translates one shader source into all supported backend formats
- Over 40 example programs demonstrate advanced rendering techniques from basics through PBR, deferred shading, and GPU-driven rendering, serving as a practical learning resource
- Battle-tested in production games and tools including the LÖVE framework and various indie titles, with a track record of stable backward compatibility
Limitations
- Provides only a GPU submission layer — no scene graph, material system, asset pipeline, physics, audio, or any higher-level abstraction is included
- The custom shader cross-compilation system (shaderc) requires learning its own GLSL-like dialect and has limitations compared to writing raw HLSL or GLSL directly
- Primarily maintained by a single developer, which poses a bus-factor concern for teams considering it as a long-term production dependency
- No formal documentation beyond header comments and example code — learning bgfx requires studying the example programs and reading source
- Debugging can be challenging since GPU errors surface at the backend API level without a high-level diagnostic layer to translate them
Background
bgfx is a cross-platform, graphics API-agnostic rendering library created and maintained by Branimir Karadžić. It provides a thin abstraction layer over a remarkable breadth of GPU backends: Direct3D 9, Direct3D 11, Direct3D 12, Metal, OpenGL 2.1+, OpenGL ES 2+, Vulkan, WebGL 1/2, WebGPU, and console-specific APIs including GNM (PS4), AGC (PS5), and NVN (Nintendo Switch). No other open-source rendering library matches this backend coverage from a single, unified C99 API.
bgfx's philosophy is deliberately minimalist: it handles GPU command submission, state management, resource creation, and shader compilation, but provides no scene graph, no material system, no asset pipeline, and no physics. This 'bring your own engine' approach makes bgfx ideal for developers building custom rendering stacks who need a portable GPU abstraction without opinionated higher-level systems. The library ships with shaderc, a cross-platform shader compiler that translates a GLSL-like shading language into backend-specific formats.
The project includes over 40 example programs demonstrating techniques ranging from basic triangle rendering to deferred shading, physically based rendering, order-independent transparency, and GPU-driven rendering. These examples serve as the primary learning resource, as bgfx has no formal documentation beyond well-commented C99 headers. bgfx is used in production by game studios, visualization tools, and development environments including the LÖVE 2D framework and various indie titles.
Quick Start
git clone https://github.com/bkaradzic/bgfx && cd bgfx && makeRelated Renderers
Community & Resources
Tutorials & Resources
Performance Benchmarks
No benchmark data available for bgfx yet.
Benchmarks will be added as more renderers are tested across our standard scene suite.
Learn about our methodology