Skip to content

Commit 7ea3e56

Browse files
committed
Rewrite introductory documentation
Provide motivation and recommend `tiny-skia` and `vello_cpu` for drawing primitives.
1 parent 94610a4 commit 7ea3e56

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ members = ["run-wasm"]
55
name = "softbuffer"
66
version = "0.4.8"
77
edition = "2021"
8-
description = "Cross-platform software buffer"
8+
description = "Cross-platform buffer for software rendering"
99
license = "MIT OR Apache-2.0"
1010
documentation = "https://docs.rs/softbuffer"
1111
repository = "https://github.com/rust-windowing/softbuffer"

README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
# Softbuffer
22

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.
44

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
822

923
## Platform support
1024

0 commit comments

Comments
 (0)