Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Gfx and glium are Rust libraries that aim to provide a "rusty" abstraction over graphics programming APIs.
Both may look similar, and one of the questions that gets asked frequently on IRC is "what are the differences between gfx and glium?". Here is a comparison table:
| Gfx | Glium
URL | <> | <>
History | Papers since Oct 2013. Really started in June 2014. | Private/confidential from Feb 2014 to July 2014. Announced and made public in July 2014[1].
Supported backends | OpenGL 2.0 to 4.5, maybe OpenGL ES 3 (untested) | OpenGL 1.0 (with the right extensions) to 4.5, maybe OpenGL ES 3 (untested)
Potential support for other backends | All: DirectX, Mantle, Metal, OpenGL NG, OpenGL ES 2, etc. | OpenGL ES 2, maybe OpenGL NG depending on what it looks like
Level of abstraction | API oriented around modern rendering techniques ("zero driver overhead"). | Maps OpenGL concepts. Uses GLSL. Not everything is exposed for safety purposes.
Stateless API[2] | Yes | Yes
Learning curve | A bit more difficult than glium | A bit easier than gfx
Context creation library | Independent of the backend (glutin, SDL, GLFW, ... all work) | Tightly coupled with glutin (aims to provide an alternative unsafe API)
Context management safety | Partially unsafe because of OpenGL, but it's hard to screw up | Totally safe
Compile-time checks | Offsets and types of vertex attributes and uniforms | Offsets and types of vertex attributes and uniforms. Strong texture typing to avoid invalid operations. Uses `&` and `&mut` to avoid invalid operations[3].
Runtime checks | Detects common errors ahead of the rendering process | Aims to detect 100% of OpenGL errors or undefined behaviors, even the most obscure ones, some of them during the rendering process
Resource destruction | Still work in progress, currently manually destructed, potentially will use linear types when they are available | RAII
Test suit | None | 174 headless OpenGL tests that can run on travis
CPU overhead (compared to raw GL) | Safety checks outside of the rendering process. Very minor. | Heavier safety checks than gfx. Uses a background thread for OpenGL context safety (could be changed in the future). Drawing involves more CPU operations than gfx. Lot of unoptimized code with many avoidable allocations.
GPU overhead (compared to raw GL) | Minor unoptimized state changes. Redundant uniform uploads. Doesn't use DSA or immutable storage. | Redundant uniform uploads
Multithreaded rendering | Draw operations can be prepared (as if they were compiled) from multiple threads ahead of the drawing | Allows safe multithreaded drawing at any time, but for best performances users are encouraged to implement themselves something similar to what gfx enforces
Supports render-to-texture | Yes | Yes
Supports multiple render targets | Yes | Yes
Supports geometry shaders | Yes (untested) | Yes
Supports uniform blocks | Yes | Yes
Supports tessellation shading | Not yet | Yes
Supports instancing | Yes | Yes
Supports commands batches | Yes for APIs that support them, emulated for OpenGL | No (and not until OpenGL supports them with an ARB or EXT extension)
Supports buffer persistent mapping | Not yet | Yes
Supports bindless textures | Not yet | Not yet (troubles with API design)
Supports transform feedback | Not yet | Not yet
Supports occlusion queries | Not yet | Not yet
Github stars | 294 | 143
Total contributors | 43 | 11
Pulse in the last month | 43 active pull requests, 41 active issues | 117 active pull requests, 92 active issues
- Both libraries have a steep learning curve if you have never done graphics programming.
- Nobody has written benchmarks that compare gfx and glium yet.
- A list of projects that use gfx/glium would be hard to write. Piston works with both but the glium backend is only two weeks old. Gfx has [Snowmew](
- Glium safely supports changing the context's attributes (for example switching windowed/fullscreen). This is out of scope of Gfx.
[1]: Even though glium was announced shortly after gfx, it was not started as a reaction to it.
[2]: "Stateless API" means that the same function calls will always produce the same result. OpenGL is often criticized for its stateful API.
[3]: OpenGL doesn't permit operating on objects while they are in a certain state (for example, when a buffer is mapped). Glium uses mutable borrows when an object is in these states (for example, mapping a buffer), and immutable borrows for other operations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment