MCPcopy Index your code
hub / github.com/emoon/rust_minifb

github.com/emoon/rust_minifb @v0.8.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.8.3 ↗ · + Follow
232 symbols 348 edges 20 files 20 documented · 9%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Crates.io Build Status Build Status

minifb is a cross platform library written in Rust 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:

Documentation Changelog

Usage

# Cargo.toml
[dependencies]
minifb = "0.8.2"

Example

extern crate minifb;

use minifb::{Key, Scale, WindowOptions};

const WIDTH: usize = 640;
const HEIGHT: usize = 360;

fn main() {
    let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT];

    let mut window = match minifb::Window::new("Test - ESC to exit", WIDTH, HEIGHT,
                                               WindowOptions::default()) {
        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() {
            *i = 0; // write something more funny here!
        }

        window.update_with_buffer(&buffer);
    }
}

Status

Currently Mac, 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!

Build instructions

cargo build
cargo run --example noise

This will run the noise example which should look something like this (Mac screenshot)

mac_screenshot

License

Licensed under either of

  • Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (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.

Extension points exported contracts — how you extend this code

InputCallback (Interface)
This trait can be implemented and set with ```set_input_callback``` to reieve a callback whene there is inputs incoming. [1 …
src/lib.rs

Core symbols most depended-on inside this repo

set_key_state
called by 201
src/key_handler.rs
clone
called by 7
src/lib.rs
to_wstring
called by 7
src/os/windows/mod.rs
add_item
called by 6
src/lib.rs
shortcut
called by 6
src/lib.rs
build
called by 6
src/lib.rs
update_with_buffer
called by 4
src/lib.rs
is_open
called by 4
src/lib.rs

Shape

Method 152
Function 41
Class 29
Enum 9
Interface 1

Languages

Rust87%
C11%
C++2%

Modules by API surface

src/lib.rs50 symbols
src/os/windows/mod.rs49 symbols
src/os/unix/mod.rs37 symbols
src/os/macos/mod.rs35 symbols
src/native/x11/X11MiniFB.c26 symbols
src/key_handler.rs12 symbols
src/native/macosx/OSXWindow.h4 symbols
src/error.rs4 symbols
examples/title_cursor.rs4 symbols
examples/menu.rs3 symbols
src/mouse_handler.rs2 symbols
src/window_flags.rs1 symbols

For agents

$ claude mcp add rust_minifb \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact