[](https://choosealicense.com/licenses/mit/)
[](https://docs.rs/miru-gl)
[](https://crates.io/crates/miru-gl)
# Miru Gl
OpenGL bindings for my personal game engine
## Overview
This crate is meant to be used in Miru project, but can be used as a standalone.
It is important to note, that Miru is pinned to minimum OpenGL Core version, which is `3.3`, to
keep it a simple as possible while also being compatible with most modern hardware.
Api is very similar to [`gl-rs`], thanks to its [`gl_generator`] crate, but [`Struct Generator`]
is used instead.
[`MiruGl`] type thinly wraps generated [`Gl`] struct.
Currently, it uses [`Rc`] to ensure that OpenGL that context isn't transferred across thread bounds,
while also avoiding dealing with lifetimes.
## Usage
```toml
[dependencies]
miru-gl = "0.1"
```
Creating a window with OpenGL context using [`glutin`]:
```rust
use glutin;
use miru_gl::MiruGl;
fn main() {
let el = glutin::EventsLoop::new();
let wb = glutin::WindowBuilder::new()
.with_title("Hello world!")
.with_dimensions(glutin::dpi::LogicalSize::new(800.0, 600.0));
let windowed_context = glutin::ContextBuilder::new()
.with_gl_profile(glutin::GlProfile::Core)
.with_gl(glutin::GlRequest::Specific(glutin::Api::OpenGl, (3, 3)))
.build_windowed(wb, &el)
.unwrap();
let windowed_context = unsafe { windowed_context.make_current().unwrap() };
// the supplied function must be of the type:
// `&fn(symbol: &'static str) -> *const std::ffi::c_void`
let gl = MiruGl::load_with(|symbol| windowed_context.get_proc_address(symbol) as *const _);
println!("{:?}", gl);
}
```
[`gl-rs`]: https://github.com/brendanzab/gl-rs/
[`gl_generator`]: https://github.com/brendanzab/gl-rs/tree/master/gl_generator
[`Struct Generator`]: https://github.com/brendanzab/gl-rs/tree/master/gl_generator#struct-generator
[`MiruGl`]: https://docs.rs/miru-gl/0.1.1/miru_gl/struct.MiruGl.html
[`Rc`]: https://doc.rust-lang.org/std/rc/struct.Rc.html
[`glutin`]: https://github.com/rust-windowing/glutin
[`Gl`]: https://docs.rs/miru-gl/0.1.1/miru_gl/struct.Gl.html