From ad3109779822a6d6b014481ac092a4e1ae06a7b5 Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Sun, 3 Jan 2016 08:29:37 +0100 Subject: [PATCH] Fixed example and added Cargo dep --- README.md | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 49aa93d..814c491 100644 --- a/README.md +++ b/README.md @@ -3,24 +3,34 @@ rust_minifb rust_minifb (Mini FrameBuffer) is a small cross platform library written in [Rust](https://www.rust-lang.org) and that makes it easy to render (32-bit) pixels in a window. An example is the best way to show how it works: +Usage +----- + +```toml +# Cargo.toml +[dependencies] +minifb = "0.2.1" +``` + +Example +------- ```rust extern crate minifb; -use minifb::*; - const WIDTH: usize = 640; const HEIGHT: usize = 360; fn main() { let mut buffer: [u32; WIDTH * HEIGHT] = [0; WIDTH * HEIGHT]; - let mut window = Window::new("Noise Test - Press ESC to exit", - WIDTH, - HEIGHT, - Scale::X1, - Vsync::No) - .unwrap(); + let mut window = match minifb::Window::new("Test - ESC to exit", WIDTH, HEIGHT, Scale::X1) { + Ok(win) => win, + Err(err) => { + println!("Unable to create window {}", err); + return; + } + }; while window.is_open() && !window.is_key_down(Key::Escape) { for i in buffer.iter_mut() { @@ -37,7 +47,7 @@ Status Currently Windows and Mac are the current supported platforms. X11 (Linux/FreeBSD/etc) support is coming soon. -Build instruction +Build instructions ------------------ ```