#graphics #ui #gui #rendering

bin+lib pix-engine

A simple, cross-platform graphics/UI engine framework with a minimal interface

8 releases

0.3.5 May 16, 2020
0.3.4 May 15, 2020
0.3.3 Mar 27, 2020
0.2.0 Mar 18, 2020
0.1.0 Feb 29, 2020

#98 in GUI

Download history 22/week @ 2021-04-10 9/week @ 2021-04-17 9/week @ 2021-04-24 12/week @ 2021-05-01 6/week @ 2021-05-08 14/week @ 2021-05-15 5/week @ 2021-05-22 4/week @ 2021-05-29 12/week @ 2021-06-05 6/week @ 2021-06-12 4/week @ 2021-06-19 2/week @ 2021-06-26 5/week @ 2021-07-03 6/week @ 2021-07-10 12/week @ 2021-07-17 12/week @ 2021-07-24

63 downloads per month
Used in 2 crates (via tetanes)

MIT/Apache

90KB
2.5K SLoC

PixEngine

Summary

A simple, cross-platform graphics/UI engine framework with a minimal interface.

Dependencies

Usage

In order to use the PixEngine, you need to implement the State interface on your application struct. There are three methods, only one of which is required:

  • on_start - Setup functionality when the application begins.
  • on_stop - Teardown functionality for when the application is closed.
  • on_update - Update functionality. This is your draw loop. It's run roughly 60 times/second.

Here's an example app skeleton:

struct App {
    // Some data fields
}

impl App {
    fn new() -> Self {
        Self {
          // Data initialization
        }
    }
}

impl State for App {
    fn on_start(&mut self, data: &mut StateData) -> PixEngineResult<bool> {
        // Setup App state. StateData contains engine specific state and functions like mouse
        // coordinates and draw functions
        // Return true to continue. False errors the application.
        Ok(true)
    }
    fn on_update(&mut self, _elapsed: f32, _data: &mut StateData) -> PixEngineResult<bool> {
        // Update App state roughly every 16ms.
        // Return true to continue, or false to abort the update loop
        Ok(true)
    }
    fn on_stop(&mut self, _data: &mut StateData) -> PixEngineResult<bool> {
        // Teardown any state or resources
        // Returning false here prevents the app from closing
        Ok(true)
    }
}

pub fn main() {
    let app = App::new();
    let width = 800;
    let height = 600;
    let vsync = true;
    let mut engine = PixEngine::new(
      "App Title".to_string(),
      app,
      800,
      600,
      vsync
    ).expect("valid engine");
    engine.run().expect("engine run");
}

Known Issues

See the github issue tracker.

License

PixEngine is licensed under the GPLv3 license. See the LICENSE.md file in the root for a copy.

Contact

For issue reporting, please use the github issue tracker. You can contact me directly here.

Contact

For issue reporting, please use the github issue tracker. You can contact me directly here.

Credits

Implementation heavily inspired by OneLoneCoder and his amazing olcPixelGameEngine project.

Also heavily influenced by p5js.

Dependencies

~0.7–1.3MB
~28K SLoC