miru-gl 0.1.1

OpenGL bindings for my personal game engine
Documentation
  • Coverage
  • 19.84%
    246 out of 1240 items documented0 out of 3 items with examples
  • Size
  • Source code size: 7.72 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 32.84 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 21s Average build duration of successful builds.
  • all releases: 21s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • rustyarch

crates.io/license docs.rs crates.io/version

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

[dependencies]
miru-gl = "0.1"

Creating a window with OpenGL context using glutin:

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);
}