min_gl


This is a small library that brings together glfw and glad to handle boilerplate code. The user only needs to create a Display, which initializes and terminates necessary stuff as a smart pointer. Hence, in the lifetime of the Display, OpenGL calls can be freely made without any other setup.


Example

```rust use glfw::WindowEvent; use min_gl::{gl, Display, Options};

fn main() { // Assume this is some application state. let mut event_count = 0u32;

// Just create and done!
// All library initialization and window creation is handled.
// They panic if an error occurs.
let mut disp = Display::new(
    // No defaults; you cannot miss anything!
    Options {
        width: 1280,
        height: 720,
        title: "Display Test".into(),
        fullscreen: false,
        decorated: true,
        msaa: Some(16),
        vsync: true,
    },
    // WindowEvent handling...
    |event| {
        event_count += 1; // Closure can modify state (FnMut).

        match event {
            WindowEvent::Key(k, _, a, _) => println!("Key `{:?}` is {:?}ed!", k, a),
            e => println!("Some {:?} happened!", e),
        }
    },
);

// Of course, you can go with more complicated main loops.
while !disp.get_window().should_close() {
    // All window events...
    disp.update();

    /* ~~~~ drawing start ~~~~ */

    gl::ClearColor(0.7, 0.5, 0.6, 1.0);

    /* ~~~~ drawing end ~~~~ */

    disp.render();
}

// No clean up; thanks to idomatic glfw-rs!
// OpenGL calls are not valid after `disp` is dropped!
println!("In total {} window events happened!", event_count);

} ```


Glad 2 was used with the fallowing options on 16.02.2022:

Perma Link


Copyright (C) 2022 Cem GeƧgel gecgelcem@outlook.com