24 releases

✓ Uses Rust 2018 edition

0.2.16 Apr 7, 2019
0.2.15 Apr 7, 2019
0.2.14 Mar 30, 2019
0.2.12 Feb 7, 2019
0.1.6 Dec 9, 2018

#41 in Game development

Download history 165/week @ 2018-12-22 35/week @ 2018-12-29 58/week @ 2019-01-05 21/week @ 2019-01-12 33/week @ 2019-01-19 20/week @ 2019-01-26 49/week @ 2019-02-02 13/week @ 2019-02-09 2/week @ 2019-02-16 8/week @ 2019-02-23 66/week @ 2019-03-02 9/week @ 2019-03-09 15/week @ 2019-03-16 136/week @ 2019-03-23 18/week @ 2019-03-30

145 downloads per month

MIT license



Build Status Crates.io Minimum Rust Version Documentation License Gitter chat

Tetra is a simple 2D game framework written in Rust. It uses SDL2 for event handling and OpenGL 3.2+ for rendering.

Note that Tetra is still extremely early in development! It may/will have bugs and missing features. That said, you're welcome to give it a go and let me know what you think :)


  • XNA/MonoGame-inspired API
  • Efficient 2D rendering, with draw call batching by default
  • Simple input handling
  • Animations/spritesheets
  • TTF font rendering
  • Multiple screen scaling algorithms, including pixel-perfect variants (for those chunky retro pixels)
  • Deterministic game loop, à la Fix Your Timestep


To add Tetra to your project, add the following line to your Cargo.toml file:

tetra = "0.2"

Tetra currently requires Rust 1.31 or higher.

You will also need to install the SDL2 native libraries - full details are provided in the documentation.


To get a simple window displayed on screen, the following code can be used:

use tetra::graphics::{self, Color};
use tetra::{Context, ContextBuilder, State};

struct GameState;

impl State for GameState {
    fn draw(&mut self, ctx: &mut Context, _dt: f64) -> tetra::Result {
        // Cornflour blue, as is tradition
        graphics::clear(ctx, Color::rgb(0.392, 0.584, 0.929));

fn main() -> tetra::Result {
    ContextBuilder::new("Hello, world!", 1280, 720)
        .run(&mut GameState)

You can see this example in action by running cargo run --example hello_world.

The full list of examples is available here.


As mentioned above, Tetra is fairly early in development, so there's likely to be bugs/flaky docs/general weirdness. Please feel free to open an issue/PR if you find something, or leave a question in the Gitter chat.

You can also contact me via Twitter, or find me lurking in the #gamedev channel on the Rust Community Discord.


~178K SLoC