rust_minifb/README.md

81 lines
2.7 KiB
Markdown
Raw Normal View History

[![Crates.io](https://img.shields.io/crates/v/minifb.svg)](https://crates.io/crates/minifb)
2016-01-05 08:58:47 +11:00
[![Build Status](https://travis-ci.org/emoon/rust_minifb.svg)](https://travis-ci.org/emoon/rust_minifb)
2016-01-05 09:18:04 +11:00
[![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)
2015-11-23 04:55:38 +11:00
2016-07-26 21:43:45 +10:00
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.
Merged window-opts to master commit 53e9cd45567a1308fdbd2e46763e15b2a3fa3d4c Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 18:31:38 2016 +0100 Correct header for v0.4.0 commit fcf64d5dfad0796fee16ce8985e66d1b3e82c5a4 Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 18:30:12 2016 +0100 More cleanup commit b7f4b187569a753656f19a74b78d8ada3fd95b70 Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 18:29:23 2016 +0100 Minor cleanup commit 7392cd4a5aaad7f0d8332082c75d6cbc41d50ca6 Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 18:28:06 2016 +0100 Updated example added Changelog link commit 236a82883a68e576ceb1e38a54b0a18fdc2e4465 Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 18:24:58 2016 +0100 Updated readme commit e6bc68721513ca66c5566a19e6bfad33875b3280 Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 18:20:42 2016 +0100 Doc fixes commit edfd688f045764b66c944d4aa616c6d48246816d Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 18:20:35 2016 +0100 Updated with 0.4.0 release info commit 784628fa9a1de93280592e634b522fd916a7588a Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 15:45:37 2016 +0100 Fixed bad comment commit 2c6d8730b566193b573afb5dc95a82987d1c4ce4 Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 15:37:52 2016 +0100 Linux support for WindowOptions commit cbf7c17c3a92d676f5707095781071016e8b90e1 Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 15:05:10 2016 +0100 Updated Windows version with WindowOptions commit ed1254245384e3e64c082a8368cbbe4a9f679efa Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 14:32:04 2016 +0100 Added get_window_handle commit e4a15f98c70facda7e7b2f30ba95a42091fa078c Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 14:30:34 2016 +0100 Cleanup + links commit 7dadb090d1037eade525093e2a541c99940e6a3a Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 14:25:41 2016 +0100 And again commit 70bdb0f88812e12bf9ca9adc55c1e52cc36c3ef9 Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 14:24:44 2016 +0100 Try link again commit b4b7b3c4cda1d958e8f9cf6a2418db68ac32bcc5 Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 14:21:54 2016 +0100 Some cleanup commit fb9845bae37f6ce9ba309b8a57128ce8c426fbca Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 13:16:23 2016 +0100 Renamed resizeable to resize commit 89c5af826612dbd887855dca3937e99856c9fcf2 Author: Daniel Collin <daniel@collin.com> Date: Sun Jan 31 12:59:57 2016 +0100 Working on making Windows a bit more generic * Added WindowOptions that can configure how the Window should look and behave better (resize, title, borderless) * Renamed update -> update_with_buffer * Added update which doesn't take a buffer (used to updated the window without buffers)
2016-02-01 04:34:05 +11:00
An example is the best way to show how it works:
2015-11-24 05:46:51 +11:00
[Changelog](https://github.com/emoon/rust_minifb/blob/master/CHANGELOG.md)
2016-01-03 18:29:37 +11:00
Usage
-----
```toml
# Cargo.toml
[dependencies]
2017-10-02 00:56:16 +11:00
minifb = "0.10.3"
2016-01-03 18:29:37 +11:00
```
Example
-------
2015-11-23 04:55:38 +11:00
2015-11-23 05:00:35 +11:00
```rust
extern crate minifb;
2015-11-23 04:55:38 +11:00
2016-11-20 17:37:49 +11:00
use minifb::{Key, WindowOptions, Window};
2015-12-25 20:37:13 +11:00
const WIDTH: usize = 640;
const HEIGHT: usize = 360;
2015-11-23 04:55:38 +11:00
2015-11-23 05:00:35 +11:00
fn main() {
let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT];
2015-11-23 04:55:38 +11:00
2016-09-18 18:25:08 +10:00
let mut window = Window::new("Test - ESC to exit",
WIDTH,
HEIGHT,
WindowOptions::default()).unwrap_or_else(|e| {
panic!("{}", e);
});
2015-11-23 04:55:38 +11:00
2015-12-25 20:37:13 +11:00
while window.is_open() && !window.is_key_down(Key::Escape) {
2015-11-23 05:00:35 +11:00
for i in buffer.iter_mut() {
2015-12-25 20:37:13 +11:00
*i = 0; // write something more funny here!
2015-11-23 05:00:35 +11:00
}
2015-11-23 04:55:38 +11:00
// We unwrap here as we want this code to exit if it fails. Real applications may want to handle this in a different way
window.update_with_buffer(&buffer).unwrap();
2015-12-25 20:37:13 +11:00
}
2015-11-23 05:01:34 +11:00
}
2015-11-23 05:00:35 +11:00
```
2015-11-23 04:55:38 +11:00
2015-11-24 05:46:51 +11:00
Status
------
2017-08-11 20:57:18 +10:00
Currently Mac, Redox, Linux and Windows (64-bit and 32-bit) are the current supported platforms. X11 (Linux/FreeBSD/etc) support has been tested on Ubuntu (x64). Bug report(s) for other OSes/CPUs are welcome!
2015-11-24 05:46:51 +11:00
2016-01-03 18:29:37 +11:00
Build instructions
2015-11-23 04:55:38 +11:00
------------------
2015-11-24 05:27:18 +11:00
```
2015-11-23 05:00:35 +11:00
cargo build
2016-03-05 03:36:28 +11:00
cargo run --example noise
2015-11-24 05:27:18 +11:00
```
2015-11-24 05:26:27 +11:00
2016-01-03 18:31:51 +11:00
This will run the [noise example](https://github.com/emoon/rust_minifb/blob/master/examples/noise.rs) which should look something like this (Mac screenshot)
2015-11-24 05:39:43 +11:00
2015-11-24 05:26:27 +11:00
![mac_screenshot](https://dl.dropboxusercontent.com/u/5205843/rust_minifb/noise_screen.png)
## License
Licensed under either of
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.