|
3 | 3 | #![allow(clippy::new_without_default)] |
4 | 4 | #![deny(unsafe_op_in_unsafe_fn)] |
5 | 5 |
|
6 | | -//! Interoperability library for Rust Windowing applications. |
| 6 | +//! # Interoperability helper between graphics crates |
7 | 7 | //! |
8 | | -//! This library provides standard types for accessing a window's platform-specific raw window |
9 | | -//! handle and platforms display handle. This does not provide any utilities for creating and |
10 | | -//! managing windows; instead, it provides a common interface that window creation libraries (e.g. |
11 | | -//! Winit, SDL) can use to easily talk with graphics libraries (e.g. gfx-hal). |
| 8 | +//! This crate is intended as an interoperability crate, that allows "producer" crates to create a |
| 9 | +//! handle to a window surface, and for this handle to be passed onwards to "consumer" crates for |
| 10 | +//! rendering to that surface. |
| 11 | +//! |
| 12 | +//! This crate does not by itself provide any utilities for creating and managing windows, nor for |
| 13 | +//! rendering into them. |
| 14 | +//! |
| 15 | +//! ## Producers |
| 16 | +//! |
| 17 | +//! Producer crates provide some sort of "window" type that implements [`HasWindowHandle`], and |
| 18 | +//! ensures that the [`WindowHandle`] returned from that is alive for as long as the window is. The |
| 19 | +//! primary example of this is [`winit`](https://docs.rs/winit/), consider that the "reference |
| 20 | +//! implementation" of a producer crate. |
| 21 | +//! |
| 22 | +//! Other cross-platform producer crates include [`sdl3`](https://docs.rs/sdl3/), |
| 23 | +//! [`sdl2`](https://docs.rs/sdl2/), [`minifb`](https://docs.rs/minifb/), |
| 24 | +//! [`glfw`](https://docs.rs/glfw/) and [`fltk`]](https://docs.rs/fltk/). |
| 25 | +//! |
| 26 | +//! Some platform-specific toolkits might also decide to implement `HasWindowHandle` for their |
| 27 | +//! types to allow more easily using them with consumer crates. Examples of this include `x11rb`, |
| 28 | +//! `ndk`, `orbclient` and `wayland-backend`. |
| 29 | +//! |
| 30 | +//! ## Consumers |
| 31 | +//! |
| 32 | +//! Consumer crates expose some sort of "surface" type that renders into a provided window handle. |
| 33 | +//! |
| 34 | +//! In general, consumer crates must either be generic over the handle type, or contain a lifetime |
| 35 | +//! to it, because on some platforms (Wayland, GBM, maybe more?) that is the only way to ensure that |
| 36 | +//! the handle is not deallocated while in use by the surface. |
| 37 | +//! ``` |
| 38 | +//! struct Surface<W: HasWindowHandle> { |
| 39 | +//! handle: W, |
| 40 | +//! } |
| 41 | +//! ``` |
| 42 | +//! |
| 43 | +//! Examples of consumer crates include [`softbuffer`](https://docs.rs/softbuffer/), |
| 44 | +//! [`glutin`](https://docs.rs/glutin/) and [`wgpu`](https://docs.rs/wgpu/), consider these |
| 45 | +//! "reference implementations" of consumer crates. Other examples include |
| 46 | +//! [`ash-window`](https://docs.rs/ash-window/) and [`pixels`](https://docs.rs/pixels/). |
| 47 | +//! |
| 48 | +//! Another type of producer is those that use the window handle to access either the platform |
| 49 | +//! widget/view or the actual window, and performs some operation that requires that. Examples of |
| 50 | +//! this include [`rfd`](https://docs.rs/rfd/), [`wry`](https://docs.rs/wry/), |
| 51 | +//! [`muda`](https://docs.rs/muda/), [`window_clipboard`](https://docs.rs/window_clipboard/), |
| 52 | +//! [`ashpd`](https://docs.rs/ashpd/), [`window-vibrancy`](https://docs.rs/window-vibrancy/), |
| 53 | +//! [`window-shadows`](https://docs.rs/window-shadows/) and |
| 54 | +//! [`native-dialog`](https://docs.rs/native-dialog/). |
12 | 55 | //! |
13 | 56 | //! ## Safety guarantees |
14 | 57 | //! |
|
0 commit comments