mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2025-01-11 11:31:32 +11:00
Fixed example and added Cargo dep
This commit is contained in:
parent
bfff11abbf
commit
ad31097798
28
README.md
28
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:
|
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
|
```rust
|
||||||
extern crate minifb;
|
extern crate minifb;
|
||||||
|
|
||||||
use minifb::*;
|
|
||||||
|
|
||||||
const WIDTH: usize = 640;
|
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: [u32; WIDTH * HEIGHT] = [0; WIDTH * HEIGHT];
|
||||||
|
|
||||||
let mut window = Window::new("Noise Test - Press ESC to exit",
|
let mut window = match minifb::Window::new("Test - ESC to exit", WIDTH, HEIGHT, Scale::X1) {
|
||||||
WIDTH,
|
Ok(win) => win,
|
||||||
HEIGHT,
|
Err(err) => {
|
||||||
Scale::X1,
|
println!("Unable to create window {}", err);
|
||||||
Vsync::No)
|
return;
|
||||||
.unwrap();
|
}
|
||||||
|
};
|
||||||
|
|
||||||
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() {
|
||||||
|
@ -37,7 +47,7 @@ Status
|
||||||
Currently Windows and Mac are the current supported platforms. X11 (Linux/FreeBSD/etc) support is coming soon.
|
Currently Windows and Mac are the current supported platforms. X11 (Linux/FreeBSD/etc) support is coming soon.
|
||||||
|
|
||||||
|
|
||||||
Build instruction
|
Build instructions
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue