#graphics #gamedev #wgpu #2d


Mid-level 2D graphics abstraction with a wgpu backend

20 releases (7 breaking)

0.8.1 Feb 29, 2020
0.7.1 Jan 8, 2020
0.5.0 Dec 4, 2019
0.4.1 Nov 25, 2019

#256 in Graphics APIs

Download history 25/week @ 2022-06-11 29/week @ 2022-06-18 44/week @ 2022-06-25 56/week @ 2022-07-02 34/week @ 2022-07-09 55/week @ 2022-07-16 68/week @ 2022-07-23 58/week @ 2022-07-30 68/week @ 2022-08-06 42/week @ 2022-08-13 59/week @ 2022-08-20 19/week @ 2022-08-27 37/week @ 2022-09-03 96/week @ 2022-09-10 29/week @ 2022-09-17 26/week @ 2022-09-24

193 downloads per month
Used in 3 crates (2 directly)

MIT license

3.5K SLoC


A mid-level 2D graphics library for rust


rgx is a 2D graphics library built on top of wgpu and Vulkan/Metal. This library aims to be "mid-level" in that it provides an API that is higher level than Vulkan/Metal, but lower level than most 2D graphics libraries in the wild, by exposing the user to concepts such as pipelines, buffers and swap chains. The goal of rgx is to provide as simple an API as possible without sacrificing performance or control over the rendering pipeline. See the examples directory to get a feel.

At this stage, the focus is on 2D bitmap graphics and sprite rendering. Basic shape rendering is also supported, but not the core strength of this library. In the future, text rendering and more complex vector rasterization may be supported - however, these are incredibly difficult to do correctly, and I would recommend looking at Mozilla's pathfinder project for these needs. rgx aims to do one thing really well, and that is bitmap rendering.


The library is split into two modules, kit, and core. The latter provides rgx's core API with no assumption on what kind of 2D graphics will be rendered, while the former exposes some useful building blocks for various use-cases, such as a shape-oriented pipeline and a sprite oriented pipeline. Users can construct their own pipelines and use them with rgx.

rgx can be used with, or without a rendering backend. To use it with, turn on the renderer feature. When used without a backend, the kit module's backend-agnostic utilities can be used.

Pipelines included in the kit

  • shape2d: for batched 2D shape rendering
  • sprite2d: for batched 2D sprite rendering


  • Batched texture rendering
  • Batched shape rendering
  • Basic primitives for sprite animation
  • Off-screen rendering support
  • Custom shader support
  • Custom pipeline support
  • Built-in depth testing


See examples/helloworld.rs for a simple usage example.

Rebuilding the shaders

To rebuild the shaders run the following:

glslc -c -Werror --target-env=vulkan ./examples/data/framebuffer.vert -o ./examples/data/framebuffer.vert.spv
glslc -c -Werror --target-env=vulkan ./examples/data/framebuffer.frag -o ./examples/data/framebuffer.frag.spv
glslc -c -Werror --target-env=vulkan ./src/kit/data/shape.frag        -o ./src/kit/data/shape.frag.spv
glslc -c -Werror --target-env=vulkan ./src/kit/data/sprite.frag       -o ./src/kit/data/sprite.frag.spv
glslc -c -Werror --target-env=vulkan ./src/kit/data/shape.vert        -o ./src/kit/data/shape.vert.spv
glslc -c -Werror --target-env=vulkan ./src/kit/data/sprite.vert       -o ./src/kit/data/sprite.vert.spv


If you find this project useful, consider supporting it by sending ₿ (Bitcoin) to 1HMfp9QFXmVUarNPmHxa1rhecZXyAPiPZd. <3

(c) 2019 Alexis Sellier
Licensed under the MIT license.


~53K SLoC