rust_minifb/README.md

39 lines
875 B
Markdown
Raw Normal View History

2015-11-23 05:00:35 +11:00
rust_minifb
2015-11-23 04:55:38 +11:00
======
2015-11-23 05:00:35 +11:00
rust_mini (Mini FrameBuffer) is a small cross platform library written in Rust and that makes it easy to render (32-bit) pixels in a window. An example is the best way to show how it works:
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
2015-11-23 05:00:35 +11:00
const WIDTH: usize = 1280;
const HEIGHT: usize = 720;
2015-11-23 04:55:38 +11:00
2015-11-23 05:00:35 +11:00
fn main() {
let mut buffer: [u32; WIDTH * HEIGHT] = [0; WIDTH * HEIGHT];
2015-11-23 04:55:38 +11:00
2015-11-23 05:00:35 +11:00
if !(minifb::open("TestWindow", WIDTH, HEIGHT)) {
return;
}
2015-11-23 04:55:38 +11:00
2015-11-23 05:00:35 +11:00
while minifb::update(&buffer) {
for i in buffer.iter_mut() {
*i = ... // write something here
}
}
2015-11-23 04:55:38 +11:00
2015-11-23 05:00:35 +11:00
minifb::close();
2015-11-23 05:01:34 +11:00
}
2015-11-23 05:00:35 +11:00
```
2015-11-23 04:55:38 +11:00
Build instructions
------------------
2015-11-24 05:27:18 +11:00
```
2015-11-23 05:00:35 +11:00
cargo build
2015-11-24 05:14:10 +11:00
2015-11-24 05:26:27 +11:00
cargo run --example noise to test the noise example which should look something like this (Mac screenshot)
2015-11-24 05:27:18 +11:00
```
2015-11-24 05:26:27 +11:00
![mac_screenshot](https://dl.dropboxusercontent.com/u/5205843/rust_minifb/noise_screen.png)