|
1 | 1 | # Softbuffer |
2 | 2 |
|
3 | | -Enables software rendering via drawing an image straight to a window. |
| 3 | +Render an image on the CPU and show it on a window in a cross-platform manner. |
4 | 4 |
|
5 | | -Softbuffer integrates with the [`raw-window-handle`](https://crates.io/crates/raw-window-handle) crate |
6 | | -to allow writing pixels to a window in a cross-platform way while using the very high quality dedicated window management |
7 | | -libraries that are available in the Rust ecosystem. |
| 5 | +There exist many libraries for doing realtime rendering on the GPU, such as `wgpu`, `blade`, |
| 6 | +`ash`, etc. This is often the sensible choice, but there are a few cases where it makes sense to |
| 7 | +render on the CPU, such as for learning purposes, drawing simple 2D scenes or GUIs, or as a |
| 8 | +fallback rendering path when a GPU isn't available. Softbuffer allows you to do this. |
| 9 | + |
| 10 | +To use Softbuffer, first create a window using `winit`, `sdl3`, or any other crate that provides a |
| 11 | +[`raw_window_handle::HasWindowHandle`]. |
| 12 | + |
| 13 | +Next, you create a [`Context`] and [`Surface`] from that window, and can now call |
| 14 | +[`Surface::buffer_mut()`] to get a [`Buffer`] that you can draw into. Once you're done drawing, call |
| 15 | +[`Buffer::present()`] to show the buffer on the window. |
| 16 | + |
| 17 | +Note that Softbuffer only provides the `&mut [...]` buffer, it does not provide any rendering |
| 18 | +primitives for drawing rectangles, circles, curves and so on. For that, you'll want to use crates |
| 19 | +like [`tiny-skia`](https://docs.rs/tiny-skia/) or [`vello_cpu`](https://docs.rs/vello_cpu/). |
| 20 | + |
| 21 | +[`raw_window_handle::HasWindowHandle`]: https://docs.rs/raw-window-handle/0.6.2/raw_window_handle/trait.HasWindowHandle.html |
8 | 22 |
|
9 | 23 | ## Platform support |
10 | 24 |
|
|
0 commit comments