OpenGL bindings for my personal game engine
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::Gl
struct.
Currently, it uses [Rc
] to ensure that OpenGL functions aren't called prematurely
and that context isn't transferred across thread bounds, while also avoiding dealing with lifetimes.
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() .withtitle("Hello world!") .withdimensions(glutin::dpi::LogicalSize::new(800.0, 600.0)); let windowedcontext = glutin::ContextBuilder::new() .withglprofile(glutin::GlProfile::Core) .withgl(glutin::GlRequest::Specific(glutin::Api::OpenGl, (3, 3))) .buildwindowed(wb, &el) .unwrap(); let windowedcontext = unsafe { windowedcontext.makecurrent().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);
}
```