#windowing #opengl

glutin

Cross-platform OpenGL context provider

97 releases (21 breaking)

✓ Uses Rust 2018 edition

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

#19 in Graphics APIs

Download history 4858/week @ 2019-02-06 5363/week @ 2019-02-13 4958/week @ 2019-02-20 5298/week @ 2019-02-27 5140/week @ 2019-03-06 5589/week @ 2019-03-13 6570/week @ 2019-03-20 4533/week @ 2019-03-27 5654/week @ 2019-04-03 6588/week @ 2019-04-10 7253/week @ 2019-04-17 7387/week @ 2019-04-24 6564/week @ 2019-05-01 6319/week @ 2019-05-08 6149/week @ 2019-05-15

26,254 downloads per month
Used in 206 crates (81 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

~2.5MB
~48K SLoC