#gamedev #graphics #rendering

polystrip

A 2D accelerated graphics rendering library

9 releases (5 breaking)

0.6.0 Mar 18, 2021
0.5.1 Feb 17, 2021
0.5.0 Jan 28, 2021
0.4.0 Jan 22, 2021
0.1.0 Oct 7, 2020

#94 in #rendering

MIT/Apache

93KB
2K SLoC

Polystrip

Build Status Crates.io

Polystrip is a 2D hardware-accelerated rendering library, primarily targeted at game development, but which could probably be used in other applications as well. Polystrip intends to be a pure-rust replacement for the sdl2 crate.

This crate should not be considered stable until the 1.0 release. Following true semver spec, this crate will likely definitely make breaking changes between development versions. The 1.0 release will come when I think this crate is fully-featured.

Simple example with winit

This example makes a window, a renderer, and only the boilerplate necessary to correctly interface with with polystrip.

let event_loop = winit::event_loop::EventLoop::new();
let window = winit::window::Window::new(&event_loop).unwrap();

let window_size = window.inner_size().to_logical(window.scale_factor());
let mut renderer = Renderer::new(&window, (window_size.width, window_size.height));

event_loop.run(move |event, _, control_flow| {
    match event {
        Event::WindowEvent { event: WindowEvent::Resized(new_size), .. } => {
            let window_size = new_size.to_logical(window.scale_factor());
            renderer.resize((window_size.width, window_size.height));
        },
        Event::MainEventsCleared => {
            let mut frame = renderer.next_frame();
            // Render in here
        },
        _ => {}
    }
});

More examples can be found in the examples directory, and can be run with cargo run --example <name>.

Dependencies

~3.5–6MB
~129K SLoC