This commit is contained in:
Daniel Collin 2017-04-02 12:20:29 +02:00
commit c9aaf7beeb
3 changed files with 11 additions and 13 deletions

View file

@ -1,12 +1,12 @@
[![Crates.io](https://img.shields.io/crates/v/minifb.svg)](https://crates.io/crates/minifb) [![Crates.io](https://img.shields.io/crates/v/minifb.svg)](https://crates.io/crates/minifb)
[![Build Status](https://travis-ci.org/emoon/rust_minifb.svg)](https://travis-ci.org/emoon/rust_minifb) [![Build Status](https://travis-ci.org/emoon/rust_minifb.svg)](https://travis-ci.org/emoon/rust_minifb)
[![Build Status](https://ci.appveyor.com/api/projects/status/sfvgqq4d4sjulkbx?svg=true)](https://ci.appveyor.com/project/emoon/rust-minifb) [![Build Status](https://ci.appveyor.com/api/projects/status/sfvgqq4d4sjulkbx?svg=true)](https://ci.appveyor.com/project/emoon/rust-minifb)
[![Documentation](https://docs.rs/minifb/badge.svg)](https://docs.rs/minifb)
minifb is a cross platform library written in [Rust](https://www.rust-lang.org) and that makes it easy to setup a window and to (optional) display a 32-bit pixel buffer. It also makes it easy to get input from keyboard and mouse. minifb is a cross platform library written in [Rust](https://www.rust-lang.org) and that makes it easy to setup a window and to (optional) display a 32-bit pixel buffer. It also makes it easy to get input from keyboard and mouse.
An example is the best way to show how it works: An example is the best way to show how it works:
[Documentation](http://prodbg.com/minifb/minifb/index.html) [Changelog](https://github.com/emoon/rust_minifb/blob/master/CHANGELOG.md)
[Changelog](https://github.com/emoon/rust_minifb/blob/window-opts/CHANGELOG.md)
Usage Usage
----- -----
@ -23,7 +23,7 @@ Example
```rust ```rust
extern crate minifb; extern crate minifb;
use minifb::{Key, Scale, WindowOptions}; use minifb::{Key, WindowOptions, Window};
const WIDTH: usize = 640; const WIDTH: usize = 640;
const HEIGHT: usize = 360; const HEIGHT: usize = 360;
@ -31,14 +31,12 @@ const HEIGHT: usize = 360;
fn main() { fn main() {
let mut buffer: Vec<u32> = vec![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, let mut window = Window::new("Test - ESC to exit",
WindowOptions::default()) { WIDTH,
Ok(win) => win, HEIGHT,
Err(err) => { WindowOptions::default()).unwrap_or_else(|e| {
println!("Unable to create window {}", err); panic!("{}", e);
return; });
}
};
while window.is_open() && !window.is_key_down(Key::Escape) { while window.is_open() && !window.is_key_down(Key::Escape) {
for i in buffer.iter_mut() { for i in buffer.iter_mut() {

View file

@ -24,7 +24,7 @@ impl InputCallback for KeyCharCallback {
fn main() { fn main() {
let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT]; let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT];
let mut window = Window::new("Noise Test - Press ESC to exit", let mut window = Window::new("Menu Test - Press ESC to exit",
WIDTH, WIDTH,
HEIGHT, HEIGHT,
WindowOptions { WindowOptions {

View file

@ -639,7 +639,7 @@ impl Window {
Self::generic_update(self, window); Self::generic_update(self, window);
self.buffer = buffer.iter().cloned().collect(); self.buffer = buffer.to_vec();
unsafe { unsafe {
user32::InvalidateRect(window, ptr::null_mut(), winapi::TRUE); user32::InvalidateRect(window, ptr::null_mut(), winapi::TRUE);
} }