#windowing #opengl

glutin

Cross-platform OpenGL context provider

97 releases (21 breaking)

✓ Uses Rust 2018 edition

new 0.21.0 Apr 21, 2019
0.20.0 Mar 10, 2019
0.19.0 Nov 10, 2018
0.17.0 Jun 28, 2018
0.0.1 Nov 12, 2014

#18 in Graphics APIs

Download history 5283/week @ 2019-01-06 4810/week @ 2019-01-13 4671/week @ 2019-01-20 4846/week @ 2019-01-27 5099/week @ 2019-02-03 5099/week @ 2019-02-10 5537/week @ 2019-02-17 5098/week @ 2019-02-24 5146/week @ 2019-03-03 5538/week @ 2019-03-10 5213/week @ 2019-03-17 6120/week @ 2019-03-24 4939/week @ 2019-03-31 6416/week @ 2019-04-07 6853/week @ 2019-04-14

23,315 downloads per month
Used in 202 crates (80 directly)

Apache-2.0

274KB
6.5K SLoC


lib.rs:

The purpose of this library is to provide an OpenGL Context on as many platforms as possible.

Building a WindowedContext<T>

A WindowedContext<T> is composed of a Window and an OpenGL Context.

Due to some operating-system-specific quirks, glutin prefers control over the order of creation of the Context and Window. Here is an example of building a WindowedContext<T>:

# fn main() {
let el = glutin::EventsLoop::new();
let wb = glutin::WindowBuilder::new()
    .with_title("Hello world!")
    .with_dimensions(glutin::dpi::LogicalSize::new(1024.0, 768.0));
let windowed_context = glutin::ContextBuilder::new()
    .build_windowed(wb, &el)
    .unwrap();
# }

You can, of course, create a RawContext<T> separately from an existing window, however that may result in an suboptimal configuration of the window on some platforms. In that case use the unsafe platform-specific [RawContextExt] available on linux and windows.

You can also produce headless Contexts via the [ContextBuilder::build_headless] function.

Dependencies

~3MB
~48K SLoC