#game #rendering #2d #gl

crow

A pixel perfect 2D rendering engine

12 releases (6 breaking)

0.7.2 Sep 25, 2021
0.7.1 Apr 6, 2020
0.7.0 Mar 30, 2020

#72 in Game dev

21 downloads per month

MIT license

295KB
2K SLoC

Crow

Documentation Crates.io License: MIT

This crate is still early in development and both highly unstable and not yet feature complete

A simple and fairly efficient pixel based 2D graphics library. crow is designed to be easy to use and should allow users to do nearly everything they want without requiring custom renderers or unsafe code.

The most recent documentation can be found here.

The latest release can be viewed at the 0.5.0 tag.

You may also want to consider looking at akari, a WIP showcase project.

This crate requires a GPU supporting OpenGL Version 3.3.

Examples

use crow::{
    glutin::{
        event::{Event, WindowEvent},
        event_loop::{ControlFlow, EventLoop},
        window::WindowBuilder,
    },
    Context, DrawConfig, Texture,
};

fn main() -> Result<(), crow::Error> {
    let event_loop = EventLoop::new();
    let mut ctx = Context::new(WindowBuilder::new(), &event_loop)?;

    let texture = Texture::load(&mut ctx, "./textures/player.png")?;

    event_loop.run(
        move |event: Event<()>, _window_target: _, control_flow: &mut ControlFlow| match event {
            Event::WindowEvent {
                event: WindowEvent::CloseRequested,
                ..
            } => *control_flow = ControlFlow::Exit,
            Event::MainEventsCleared => ctx.window().request_redraw(),
            Event::RedrawRequested(_) => {
                let mut surface = ctx.surface();
                ctx.clear_color(&mut surface, (0.4, 0.4, 0.8, 1.0));
                ctx.draw(&mut surface, &texture, (100, 150), &DrawConfig::default());
                ctx.present(surface).unwrap();
            }
            _ => (),
        },
    )
}

Dependencies

~5.5–7.5MB
~124K SLoC