59 releases

0.8.0 Mar 17, 2023
0.7.0 Mar 23, 2022
0.7.0-alpha1 Jan 7, 2022
0.6.7 Nov 5, 2021
0.2.2 Dec 24, 2018

#177 in Game dev

Download history 373/week @ 2023-08-16 447/week @ 2023-08-23 147/week @ 2023-08-30 356/week @ 2023-09-06 324/week @ 2023-09-13 118/week @ 2023-09-20 154/week @ 2023-09-27 177/week @ 2023-10-04 328/week @ 2023-10-11 329/week @ 2023-10-18 327/week @ 2023-10-25 383/week @ 2023-11-01 277/week @ 2023-11-08 291/week @ 2023-11-15 350/week @ 2023-11-22 311/week @ 2023-11-29

1,274 downloads per month
Used in 7 crates

MIT license



Build Status Crates.io Documentation License

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


Tetra is no longer being actively developed, as of January 2022. Bug fixes and dependency updates may still happen from time to time, but no new features are planned. Feature PRs may be accepted, as long as they do not come with a large maintainence burden - please open an issue/discussion thread if you're thinking about making any large changes!

For more information, see this blog post.


  • XNA/MonoGame-inspired API
  • Efficient 2D rendering, with draw call batching by default
  • Easy input handling, via polling or events, with support for gamepads
  • Deterministic game loop by default, à la Fix Your Timestep
  • Common building blocks built-in, such as:
    • Font rendering
    • Cameras
    • Screen scaling


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

tetra = "0.8"

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) -> tetra::Result {
        // Cornflower 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(|_| Ok(GameState))

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

The full list of examples is available here.


Tetra is fairly early in development, so you might run into bugs/flaky docs/general weirdness. Please feel free to open an issue/PR if you find something! You can also contact me via Twitter or the Rust Game Development Discord.


~1M SLoC