Skip to content

๐Ÿ•น Build cross-platform GUI apps with Rust

License

Notifications You must be signed in to change notification settings

craigfay/open_ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Welcome! ๐Ÿ‘‹

OpenUI is a developer friendly Rust library for creating cross-platform GUI apps. This is a great choice for anyone who doesn't want to work directly with OpenGL, or wrappers like Glutin and Glium, and for anyone who doesn't need an entire desktop web framework like Electron or Tauri.

Try It Yourself! ๐Ÿ•น

It's extremely easy to try out the OpenUI example project, a 1980's-style Snake Game. Use the arrow keys and spacebar to play.

git clone git@github.com:craigfay/open_ui.git && cd open_ui
cargo run

Developer Installation ๐Ÿ’ฝ

Add OpenUI as a dependency in any Cargo project:

# Cargo.toml
[dependencies]
open_ui = "*"

Build Your Own App with OpenUI ๐Ÿงฑ

To create a Rust program that renders a UI, simply define a struct that implements the UIController interface:

use open_ui::UIController;

// Define a struct to hold your application data
struct SnakeGame {};


// Implement the `UIController` interface to define application behavior
impl UIController for SnakeGame {

    fn blueprint(&self) -> UIBlueprint {
        // This function wil be called once before the application opens,
        // and determines the initial settings of the rendering window.
    }

    fn next_frame(&mut self) -> Option<&RgbaImage> {
        // This function will be called called every frame,
        // and returns the contents of the next render-able frame,
        // or `None` if the application should terminate.
    }

    fn process_events(&mut self, events: &Vec<UIEvent>) {
        // This function will be called every frame, receiving
        // input events, and usually responding by modifying state.
    }
}

Then, pass an instance of that struct into UI::launch():

use open_ui::UI;

fn main() {
    let application = SnakeGame::new();
    UI::launch(application);
}

Caveats

OpenUI does all its work on the CPU, and does not attempt (at this time) to leverage GPU acceleration. This means that its probably not suitable for workloads involving realistic 3D rendering. That said, OpenUI is more than capable of handling almost any 2D graphics workload on modern machines.

Resources ๐Ÿ“–

About

๐Ÿ•น Build cross-platform GUI apps with Rust

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages