9个版本 (4个破坏性版本)
0.4.2 | 2022年7月25日 |
---|---|
0.4.1 | 2022年7月20日 |
0.3.1 | 2022年7月15日 |
0.2.1 | 2022年5月31日 |
0.0.3 | 2022年2月16日 |
#397 in 图形API
用于 2 个库
87KB
1.5K SLoC
鹦鹉
一个针对wgpu的重复中间件库。
关于
鹦鹉基本上是对easygpu的重新实现,适用于鸽子。因此,其开发主要是由鸽子的需求驱动的。它处理与wgpu相关的某些样板代码,并提供各种围绕wgpu类型的包装,使其更容易使用,同时仍然给您以控制权。鹦鹉不是魔法,您需要足够了解wgpu才能正确使用它。
使用方法
在开始使用鹦鹉之前,建议您阅读学习wgpu,因为它是了解wgpu及其工作方式的绝佳资源。作为基本设置,您将创建一个wgpu实例和一个窗口,使用winit,然后是Painter。从那里起,就由您来决定了。
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);
// ...
}
我已经创建了一些示例(在示例文件夹中),这些示例展示了鹦鹉的能力,并希望能给您一个如何使用鹦鹉的思路。要运行它们,请使用 cargo run --example=ExampleNameHere
依赖关系
~9–21MB
~290K SLoC