mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2024-12-23 19:31:30 +11:00
Improve documentation for method update_with_buffer
of Window
(#89)
This commit is contained in:
parent
c56ea6dae9
commit
0e3bf4a7e2
15
src/lib.rs
15
src/lib.rs
|
@ -222,14 +222,23 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Updates the window with a 32-bit pixel buffer. Notice that the buffer needs to be at least
|
/// Updates the window with a 32-bit pixel buffer. The encoding for each pixel is `0RGB`:
|
||||||
/// the size of the created window
|
/// The upper 8-bits are ignored, the next 8-bits are for the red channel, the next 8-bits
|
||||||
|
/// afterwards for the green channel, and the lower 8-bits for the blue channel.
|
||||||
|
///
|
||||||
|
/// Notice that the buffer needs to be at least the size of the created window.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// # use minifb::*;
|
/// # use minifb::*;
|
||||||
/// let mut buffer: Vec<u32> = vec![0; 640 * 400];
|
/// fn from_u8_rgb(r: u8, g: u8, b: u8) -> u32 {
|
||||||
|
/// let (r, g, b) = (r as u32, g as u32, b as u32);
|
||||||
|
/// (r << 16) | (g << 8) | b
|
||||||
|
/// }
|
||||||
|
/// let azure_blue = from_u8_rgb(0, 127, 255);
|
||||||
|
///
|
||||||
|
/// let mut buffer: Vec<u32> = vec![azure_blue; 640 * 400];
|
||||||
///
|
///
|
||||||
/// let mut window = Window::new("Test", 640, 400, WindowOptions::default()).unwrap();
|
/// let mut window = Window::new("Test", 640, 400, WindowOptions::default()).unwrap();
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in a new issue