nical / lyon

2D graphics rendering on the GPU in rust using path tessellation.
Other
2.3k stars 142 forks source link

Is it possible to convert VertexBuffers into a bitmap ? #317

Closed Brooooooklyn closed 6 years ago

Brooooooklyn commented 6 years ago

Sorry, I'm new to graphics programing, and I need to generate bitmap directly. And I want to know if there is a way to generate bitmap like: &[u8] from VertexBuffers. Thank you !

nical commented 6 years ago

Hi! the usual way to use the vertex buffers is to write a bit of OpenGL/gfx-rs/glium/etc and render it on the GPU (see the examples in the repository). It is also technically possible to render the triangles directly on the CPU using the toy triangle rasterizer but this piece of code is mostly meant to write automated tests so it's not particularly ergonomic or fast, and it doesn't do any anti-aliasing.

If you need something more polished/powerful to render triangles on the CPU, there are probably a few crates out there for software triangle rendering like https://github.com/novacrazy/rust-softrender