Documentation on docs.rs Travis Build Status AppVeyor Build Status crates.io Gitter Chat
Documentation | Blog

gfx-rs

gfx is a high-performance, bindless graphics API for the Rust programming language. It aims to be the default API for Rust graphics: for one-off applications, or higher level libraries or engines.

Motivation

Features

Graphics backends: - OpenGL 2.1+ - OpenGL ES2+ (works on Android) - Direct3D 11 - Metal (WIP 75%) - Vulkan (WIP 40%)

Hardware features: - [x] off-screen render targets - [x] multisampling - [x] instancing - [x] geometry shaders - [x] tessellation - [ ] computing - [x] persistent mapping

Who's using it?

Biggest open-source projects are: - Amethyst engine - Piston engine - 2d graphics - LazyBox engine - Zone of Control game - Vange-rs game - Claymore game/engine

Shiny screens, including some older projects:

Snowmew Hematite LazyBox Vange-rs Claymore ZoC Petri

Getting started

The gfx-rs git repository contains a number of examples. Those examples are automatically downloaded if you clone the gfx directory:

$ cd <my_dir>
$ git clone https://github.com/gfx-rs/gfx

where <my_dir> is a directory name of your choice. Once gfx is downloaded you can build any of the gfx examples. The examples are listed in the <my_dir>/gfx/Cargo.toml file. For example try:

$ cd gfx
$ cargo run --example cube

If you compile the example for the first time, it may take some while since all dependencies must be compiled too.

If you want to build your own stand-alone gfx program, add the following to your new Cargo.toml:

[dependencies]
gfx = "0.13"

For gfx to work, it needs access to the graphics system of the OS. This is typically provided through some window initialization API. gfx can use a couple of those to acquire graphical contexts. For example; glfw or glutin.

To see how the graphic context is acquired, see the cube example or the triangle example.

To use glutin, for example, your Cargo.toml must be extended with the following dependencies:

[dependencies]
...
glutin ="*"
gfx_window_glutin = "*"

You may want to inspect <my_dir>/gfx/Cargo.toml for other modules typically used in gfx programs.

Note

gfx is still in development. API may change with new backends/features to be implemented. If you are interested in helping out, please contact the developers on Gitter.