Heap allocate drawing buffer

On some system it seems that the stack is quite small so now we heap
allocate the buffer instead. Also updated the docs and examples using
that instead of being on the stack. Bumped version to 0.2.4

Closes #8
This commit is contained in:
Daniel Collin 2016-01-05 21:29:52 +01:00
parent 57b734457e
commit 49eba1bc05
3 changed files with 6 additions and 6 deletions

View file

@ -12,7 +12,7 @@ Usage
```toml ```toml
# Cargo.toml # Cargo.toml
[dependencies] [dependencies]
minifb = "0.2.3" minifb = "0.2.4"
``` ```
Example Example
@ -25,7 +25,7 @@ const WIDTH: usize = 640;
const HEIGHT: usize = 360; const HEIGHT: usize = 360;
fn main() { fn main() {
let mut buffer: [u32; WIDTH * HEIGHT] = [0; WIDTH * HEIGHT]; let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT];
let mut window = match minifb::Window::new("Test - ESC to exit", WIDTH, HEIGHT, Scale::X1) { let mut window = match minifb::Window::new("Test - ESC to exit", WIDTH, HEIGHT, Scale::X1) {
Ok(win) => win, Ok(win) => win,

View file

@ -1,6 +1,6 @@
extern crate minifb; extern crate minifb;
use minifb::*; use minifb::{Window, Key, Scale};
const WIDTH: usize = 640; const WIDTH: usize = 640;
const HEIGHT: usize = 360; const HEIGHT: usize = 360;
@ -10,7 +10,7 @@ fn main() {
let mut carry; let mut carry;
let mut seed = 0xbeefu32; let mut seed = 0xbeefu32;
let mut buffer: [u32; WIDTH * HEIGHT] = [0; WIDTH * HEIGHT]; let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT];
let mut window = match Window::new("Noise Test - Press ESC to exit", WIDTH, HEIGHT, Scale::X2) { let mut window = match Window::new("Noise Test - Press ESC to exit", WIDTH, HEIGHT, Scale::X2) {
Ok(win) => win, Ok(win) => win,

View file

@ -183,7 +183,7 @@ use self::os::unix as imp;
/// const WIDTH: usize = 640; /// const WIDTH: usize = 640;
/// const HEIGHT: usize = 360; /// const HEIGHT: usize = 360;
/// ///
/// let mut buffer: [u32; WIDTH * HEIGHT] = [0; WIDTH * HEIGHT]; /// let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT];
/// ///
/// let mut window = match Window::new("Test - Press ESC to exit", WIDTH, HEIGHT, Scale::X1).unwrap() /// let mut window = match Window::new("Test - Press ESC to exit", WIDTH, HEIGHT, Scale::X1).unwrap()
/// ///
@ -222,7 +222,7 @@ impl Window {
/// # Examples /// # Examples
/// ///
/// ```ignore /// ```ignore
/// let mut buffer: [u32; 640 * 400] = [0; 640 * 400]; /// let mut buffer: Vec<u32> = vec![0; 640 * 400];
/// ///
/// let mut window = match Window::new("Test", 640, 400, Scale::X1).unwrap(); /// let mut window = match Window::new("Test", 640, 400, Scale::X1).unwrap();
/// ///