#parrot #graphics #wgpu #easygpu

pigeon-parrot

A wrapper around wgpu for pigeon, designed to make things easier

6 releases

Uses new Rust 2021

0.2.1 May 31, 2022
0.2.0 Apr 18, 2022
0.1.0 Mar 26, 2022
0.0.3 Feb 16, 2022
Download history 9/week @ 2022-03-11 12/week @ 2022-03-18 19/week @ 2022-03-25 4/week @ 2022-04-01 4/week @ 2022-04-08 20/week @ 2022-04-15 7/week @ 2022-04-22 32/week @ 2022-04-29 36/week @ 2022-05-06 88/week @ 2022-05-13 18/week @ 2022-05-20 46/week @ 2022-05-27 48/week @ 2022-06-03 7/week @ 2022-06-17 4/week @ 2022-06-24

68 downloads per month
Used in pigeon-2d

MIT license

87KB
1.5K SLoC

Parrot

Latest version Docs License

A repeated middleware library for wgpu.

About

Parrot is more or less a re-implementation of easygpu for pigeon. Hence its development is primarily driven by the demands of pigeon. It deals with some of the boilerplate code that comes with wgpu and provides various wrappers around wgpu's types so they are easier to work with, while still giving you control. Parrot isn't magic and requires you understand wgpu well enough to be used properly.

Usage

Before using parrot I recommend reading learn wgpu as it's an excellent resource to get you aquainted with wgpu and how it works. As a basic setup you will create a wgpu instance and a window using winit and then a Painter. From there it is up to you.

fn main() {
    // Initialise the logging output at info level only from parrot
    env_logger::builder().filter_module("pigeon_parrot", log::LevelFilter::Info).init();
    
    // Create an event loop
    let event_loop = winit::event_loop::EventLoop::new();
    // Create a window to draw to
    let window = winit::window::WindowBuilder::new().with_title("Triangle :D").build(&event_loop).unwrap();

    // Create a wgpu instance
    let instance = wgpu::Instance::new(wgpu::Backends::GL);
    let surface = unsafe { instance.create_surface(&window) };

    // Create the painter
    let mut painter = pollster::block_on(parrot::Painter::for_surface(surface, &instance, 1)).unwrap();

    // Get the size of the window
    let winsize = window.inner_size();

    // Get the preferred texture format for the surface
    let pref_format = painter.preferred_format();

    // Configure the surface
    painter.configure(euclid::Size2D::new(winsize.width, winsize.height), wgpu::PresentMode::Fifo, pref_format);

    // ...
}

I have created some examples (in the examples folder) that demonstrate parrots capabilities and will hopefully give you an idea of how to use parrot. To run them use cargo run --example=ExampleNameHere

Dependencies

~6–9.5MB
~194K SLoC