Skip to content

Commit 51a748c

Browse files
Merge pull request glium#1736 from est31/master
Update dependencies, unbreak examples
2 parents f36ceca + 0c0123c commit 51a748c

File tree

8 files changed

+48
-35
lines changed

8 files changed

+48
-35
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## Version 0.24.0 (2019-04-08)
4+
5+
- Updated glutin to version 0.20. See the glutin release notes [here](https://github.com/tomaka/glutin/blob/master/CHANGELOG.md#version-0200-2019-03-09).
6+
- Depth comparison and shadow mapping ([#1679](https://github.com/glium/glium/pull/1679)).
7+
38
## Version 0.23.0 (2018-12-05)
49

510
- Updated glutin to version 0.19. See the glutin release notes [here](https://github.com/tomaka/glutin/blob/master/CHANGELOG.md#version-0190-2018-11-09).

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "glium"
3-
version = "0.23.0"
3+
version = "0.24.0"
44
authors = ["Pierre Krieger <[email protected]>"]
55
description = """
66
Elegant and safe OpenGL wrapper.
@@ -35,7 +35,7 @@ unstable = [] # used for benchmarks
3535
test_headless = [] # used for testing headless display
3636

3737
[dependencies.glutin]
38-
version = "0.19"
38+
version = "0.20"
3939
features = []
4040
optional = true
4141

@@ -46,11 +46,11 @@ smallvec = "0.6"
4646
fnv = "1.0.5"
4747

4848
[build-dependencies]
49-
gl_generator = "0.10"
49+
gl_generator = "0.11"
5050

5151
[dev-dependencies]
52-
cgmath = "0.16"
52+
cgmath = "0.17"
5353
genmesh = "0.6"
54-
image = "0.20"
54+
image = "0.21"
5555
obj = { version = "0.9", features = ["genmesh"] }
5656
rand = "0.6"

examples/gpgpu.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22
extern crate glium;
33
extern crate rand;
44
use glium::glutin;
5+
use glutin::dpi::PhysicalSize;
56

67
fn main() {
78
let event_loop = glium::glutin::EventsLoop::new();
89
let context_builder = glutin::ContextBuilder::new();
9-
let context = glutin::Context::new(&event_loop, context_builder, false).unwrap();
10+
let size = PhysicalSize {
11+
width: 800.0,
12+
height: 600.0,
13+
};
14+
let context = context_builder.build_headless(&event_loop, size).unwrap();
1015
let display = glium::backend::glutin::headless::Headless::new(context).unwrap();
1116

1217
let program = glium::program::ComputeShader::from_source(&display, r#"\

examples/manual-creation.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ There are three concepts in play:
1919
extern crate glium;
2020

2121
use glium::Surface;
22-
use glium::glutin::{self, GlContext};
22+
use glium::glutin::{self, ContextTrait};
2323

2424
use std::rc::Rc;
2525
use std::os::raw::c_void;
@@ -29,13 +29,13 @@ fn main() {
2929
// note that it's just `build` and not `build_glium`
3030
let mut events_loop = glutin::EventsLoop::new();
3131
let window = glutin::WindowBuilder::new();
32-
let context = glutin::ContextBuilder::new();
33-
let gl_window = Rc::new(glutin::GlWindow::new(window, context, &events_loop).unwrap());
32+
let context_builder = glutin::ContextBuilder::new();
33+
let gl_window = Rc::new(context_builder.build_windowed(window, &events_loop).unwrap());
3434

3535
// in order to create our context, we will need to provide an object which implements
3636
// the `Backend` trait
3737
struct Backend {
38-
gl_window: Rc<glutin::GlWindow>,
38+
gl_window: Rc<glutin::WindowedContext>,
3939
}
4040

4141
unsafe impl glium::backend::Backend for Backend {

examples/shadow_mapping.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ extern crate cgmath;
55
use cgmath::SquareMatrix;
66
use glium::{glutin, Surface};
77
use std::time::Instant;
8+
use glutin::dpi::LogicalSize;
89

910
fn main() {
10-
let win_size = (800, 600);
11+
let win_size = LogicalSize {
12+
width: 800.0,
13+
height: 600.0,
14+
};
1115
let shadow_map_size = 1024;
1216

1317
// Create the main window
1418
let mut events_loop = glutin::EventsLoop::new();
1519
let window = glutin::WindowBuilder::new()
16-
.with_dimensions(win_size.0, win_size.1)
20+
.with_dimensions(win_size)
1721
.with_title("Shadow Mapping");
1822
let context = glutin::ContextBuilder::new().with_vsync(true);
1923
let display = glium::Display::new(window, context, &events_loop).unwrap();
@@ -161,7 +165,7 @@ fn main() {
161165
// Handle events
162166
events_loop.poll_events(|event| match event {
163167
glutin::Event::WindowEvent { event, .. } => match event {
164-
glutin::WindowEvent::Closed => exit = true,
168+
glutin::WindowEvent::CloseRequested => exit = true,
165169
glutin::WindowEvent::KeyboardInput { input, .. } => if input.state == glutin::ElementState::Pressed {
166170
if let Some(key) = input.virtual_keycode {
167171
match key {
@@ -227,7 +231,7 @@ fn main() {
227231

228232
// Render the scene from the camera's point of view
229233
// ===============================================================================
230-
let screen_ratio = (win_size.0 as f32) / (win_size.1 as f32);
234+
let screen_ratio = (win_size.width / win_size.height) as f32;
231235
let perspective_matrix: cgmath::Matrix4<f32> = cgmath::perspective(cgmath::Deg(45.0), screen_ratio, 0.0001, 100.0);
232236
let camera_x = 3.0 * camera_t.cos();
233237
let camera_z = 3.0 * camera_t.sin();

src/backend/glutin/headless.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ use {Frame, IncompatibleOpenGl, SwapBuffersError};
44
use debug;
55
use context;
66
use backend::{self, Backend};
7+
use backend::glutin::glutin::ContextTrait;
78
use std::rc::Rc;
89
use std::ops::Deref;
910
use std::os::raw::c_void;
1011
use super::glutin;
11-
use super::glutin::GlContext;
12-
1312

1413
/// A headless glutin context.
1514
pub struct Headless {

src/backend/glutin/mod.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use context;
1818
use backend;
1919
use backend::Context;
2020
use backend::Backend;
21-
use glutin::GlContext;
21+
use backend::glutin::glutin::ContextTrait;
2222
use std;
2323
use std::cell::{Cell, RefCell, Ref};
2424
use std::error::Error;
@@ -37,15 +37,15 @@ pub struct Display {
3737
// contains everything related to the current context and its state
3838
context: Rc<context::Context>,
3939
// The glutin Window alongside its associated GL Context.
40-
gl_window: Rc<RefCell<glutin::GlWindow>>,
40+
gl_window: Rc<RefCell<glutin::WindowedContext>>,
4141
// Used to check whether the framebuffer dimensions have changed between frames. If they have,
4242
// the glutin context must be resized accordingly.
4343
last_framebuffer_dimensions: Cell<(u32, u32)>,
4444
}
4545

4646
/// An implementation of the `Backend` trait for glutin.
4747
#[derive(Clone)]
48-
pub struct GlutinBackend(Rc<RefCell<glutin::GlWindow>>);
48+
pub struct GlutinBackend(Rc<RefCell<glutin::WindowedContext>>);
4949

5050
/// Error that can happen while creating a glium display.
5151
#[derive(Debug)]
@@ -67,44 +67,44 @@ impl Display {
6767
events_loop: &glutin::EventsLoop,
6868
) -> Result<Self, DisplayCreationError>
6969
{
70-
let gl_window = try!(glutin::GlWindow::new(window_builder, context_builder, events_loop));
70+
let gl_window = glutin::WindowedContext::new_windowed(window_builder, context_builder, events_loop)?;
7171
Self::from_gl_window(gl_window).map_err(From::from)
7272
}
7373

7474
/// Create a new glium `Display`.
7575
///
7676
/// Performs a compatibility check to make sure that all core elements of glium are supported
7777
/// by the implementation.
78-
pub fn from_gl_window(gl_window: glutin::GlWindow) -> Result<Self, IncompatibleOpenGl> {
78+
pub fn from_gl_window(gl_window: glutin::WindowedContext) -> Result<Self, IncompatibleOpenGl> {
7979
Self::with_debug(gl_window, Default::default())
8080
}
8181

8282
/// Create a new glium `Display`.
8383
///
8484
/// This function does the same as `build_glium`, except that the resulting context
8585
/// will assume that the current OpenGL context will never change.
86-
pub unsafe fn unchecked(gl_window: glutin::GlWindow) -> Result<Self, IncompatibleOpenGl> {
86+
pub unsafe fn unchecked(gl_window: glutin::WindowedContext) -> Result<Self, IncompatibleOpenGl> {
8787
Self::unchecked_with_debug(gl_window, Default::default())
8888
}
8989

9090
/// The same as the `new` constructor, but allows for specifying debug callback behaviour.
91-
pub fn with_debug(gl_window: glutin::GlWindow, debug: debug::DebugCallbackBehavior)
91+
pub fn with_debug(gl_window: glutin::WindowedContext, debug: debug::DebugCallbackBehavior)
9292
-> Result<Self, IncompatibleOpenGl>
9393
{
9494
Self::new_inner(gl_window, debug, true)
9595
}
9696

9797
/// The same as the `unchecked` constructor, but allows for specifying debug callback behaviour.
9898
pub unsafe fn unchecked_with_debug(
99-
gl_window: glutin::GlWindow,
99+
gl_window: glutin::WindowedContext,
100100
debug: debug::DebugCallbackBehavior,
101101
) -> Result<Self, IncompatibleOpenGl>
102102
{
103103
Self::new_inner(gl_window, debug, false)
104104
}
105105

106106
fn new_inner(
107-
gl_window: glutin::GlWindow,
107+
gl_window: glutin::WindowedContext,
108108
debug: debug::DebugCallbackBehavior,
109109
checked: bool,
110110
) -> Result<Self, IncompatibleOpenGl>
@@ -120,10 +120,10 @@ impl Display {
120120
})
121121
}
122122

123-
/// Rebuilds the Display's `GlWindow` with the given window and context builders.
123+
/// Rebuilds the Display's `WindowedContext` with the given window and context builders.
124124
///
125-
/// This method ensures that the new `GlWindow`'s `Context` will share the display lists of the
126-
/// original `GlWindow`'s `Context`.
125+
/// This method ensures that the new `WindowedContext`'s `Context` will share the display lists of the
126+
/// original `WindowedContext`'s `Context`.
127127
pub fn rebuild(
128128
&self,
129129
window_builder: glutin::WindowBuilder,
@@ -135,11 +135,11 @@ impl Display {
135135
let new_gl_window = {
136136
let gl_window = self.gl_window.borrow();
137137
let context_builder = context_builder.with_shared_lists(gl_window.context());
138-
try!(glutin::GlWindow::new(window_builder, context_builder, events_loop))
138+
glutin::WindowedContext::new_windowed(window_builder, context_builder, events_loop)?
139139
};
140140

141141
{
142-
// Replace the stored GlWindow with the new one.
142+
// Replace the stored WindowedContext with the new one.
143143
let mut gl_window = self.gl_window.borrow_mut();
144144
std::mem::replace(&mut (*gl_window), new_gl_window);
145145
}
@@ -151,9 +151,9 @@ impl Display {
151151
Ok(())
152152
}
153153

154-
/// Borrow the inner glutin GlWindow.
154+
/// Borrow the inner glutin WindowedContext.
155155
#[inline]
156-
pub fn gl_window(&self) -> Ref<glutin::GlWindow> {
156+
pub fn gl_window(&self) -> Ref<glutin::WindowedContext> {
157157
self.gl_window.borrow()
158158
}
159159

@@ -234,9 +234,9 @@ impl backend::Facade for Display {
234234
}
235235

236236
impl Deref for GlutinBackend {
237-
type Target = Rc<RefCell<glutin::GlWindow>>;
237+
type Target = Rc<RefCell<glutin::WindowedContext>>;
238238
#[inline]
239-
fn deref(&self) -> &Rc<RefCell<glutin::GlWindow>> {
239+
fn deref(&self) -> &Rc<RefCell<glutin::WindowedContext>> {
240240
&self.0
241241
}
242242
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Easy-to-use, high-level, OpenGL3+ wrapper.
44
Glium is based on glutin - a cross-platform crate for building an OpenGL window and handling
55
application events.
66
7-
Glium provides a **Display** which extends the **glutin::GlWindow** with a high-level, safe API.
7+
Glium provides a **Display** which extends the **glutin::WindowedContext** with a high-level, safe API.
88
99
# Initialization
1010

0 commit comments

Comments
 (0)