Skip to content

Commit

Permalink
Update to winit 0.16.0 + release glutin 0.17.0 (#1035)
Browse files Browse the repository at this point in the history
* Use super-dpi winit branch

* Update for new DPI API

* Improved type names

* Fixed iOS

* Update for new import structure

* Use winit 0.16.0

* resize method takes PhysicalSize

* Updated examples

* Release glutin 0.17.0

* Build with icon_loading features on docs.rs

* Add CHANGELOG entry for iOS changes

* Test against 1.24.1 on CI
  • Loading branch information
francesca64 authored Jun 28, 2018
1 parent 0c3fbdd commit cb05e03
Show file tree
Hide file tree
Showing 22 changed files with 386 additions and 830 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ language: rust

rust:
- nightly
- beta
- stable
- 1.24.1

cache: cargo

Expand All @@ -24,7 +26,7 @@ os:
- linux
- osx

after_success:
after_success:
- |
[ $TRAVIS_BRANCH = master ] &&
[ $TRAVIS_PULL_REQUEST = false ] &&
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Unreleased

# Version 0.17.0 (2018-06-27)

- Fix regression that prevented automatic graphics switching in MacOS ([#980](https://github.com/tomaka/glutin/issues/980))
- Add `ContextBuilder::with_double_buffer` function
- Add `ContextBuilder::with_hardware_acceleration` function
- Work around a presumed bug Android emulator bug
that would cause context creation to return `CreationError::OpenGlVersionNotSupported`
in some configurations
([1036](https://github.com/tomaka/glutin/pull/1036))
([#1036](https://github.com/tomaka/glutin/pull/1036))
- Update winit dependency to 0.16.0. See [winit's CHANGELOG](https://github.com/tomaka/winit/blob/v0.16.0/CHANGELOG.md#version-0160-2018-06-25) for more info.
- The iOS backend no longer fails to compile.

# Version 0.16.0 (2018-05-09)

Expand Down
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "glutin"
version = "0.16.0"
version = "0.17.0"
authors = ["The glutin contributors, Pierre Krieger <[email protected]>"]
description = "Cross-platform OpenGL context provider."
keywords = ["windowing", "opengl"]
Expand All @@ -10,14 +10,17 @@ repository = "https://github.com/tomaka/glutin"
documentation = "https://docs.rs/glutin"
build = "build.rs"

[package.metadata.docs.rs]
features = ["icon_loading"]

[features]
icon_loading = ["winit/icon_loading"]

[dependencies]
lazy_static = "1"
libc = "0.2"
shared_library = "0.1.0"
winit = "0.15.0"
winit = "0.16.0"

[build-dependencies]
gl_generator = "0.9"
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ gl = "*"
extern crate gl;
extern crate glutin;

use glutin::dpi::*;
use glutin::GlContext;

fn main() {
let mut events_loop = glutin::EventsLoop::new();
let window = glutin::WindowBuilder::new()
.with_title("Hello, world!")
.with_dimensions(1024, 768);
.with_dimensions(LogicalSize::new(1024.0, 768.0));
let context = glutin::ContextBuilder::new()
.with_vsync(true);
let gl_window = glutin::GlWindow::new(window, context, &events_loop).unwrap();
Expand All @@ -64,7 +65,10 @@ fn main() {
match event {
glutin::Event::WindowEvent{ event, .. } => match event {
glutin::WindowEvent::CloseRequested => running = false,
glutin::WindowEvent::Resized(w, h) => gl_window.resize(w, h),
glutin::WindowEvent::Resized(logical_size) => {
let dpi_factor = gl_window.get_hidpi_factor();
gl_window.resize(logical_size.to_physical(dpi_factor));
},
_ => ()
},
_ => ()
Expand Down
13 changes: 10 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
environment:
matrix:
- TARGET: x86_64-pc-windows-msvc
CHANNEL: nightly
- TARGET: x86_64-pc-windows-msvc
CHANNEL: stable
- TARGET: x86_64-pc-windows-msvc
CHANNEL: 1.24.1
- TARGET: i686-pc-windows-msvc
CHANNEL: nightly
- TARGET: i686-pc-windows-gnu
CHANNEL: nightly
install:
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe"
- rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
- SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- rustup-init -yv --default-toolchain %CHANNEL% --default-host %TARGET%
- SET PATH=%PATH%;%USERPROFILE%\.cargo\bin
- SET PATH=%PATH%;C:\MinGW\bin
- rustc -V
- cargo -V
Expand Down
55 changes: 0 additions & 55 deletions examples/cursor.rs

This file was deleted.

51 changes: 33 additions & 18 deletions examples/fullscreen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,40 @@ fn main() {

let gl = support::load(&gl_window);

events_loop.run_forever(|event| {
use glutin::{ControlFlow, Event, WindowEvent, VirtualKeyCode};
println!("{:?}", event);
match event {
Event::WindowEvent { event, .. } => match event {
WindowEvent::CloseRequested => return ControlFlow::Break,
WindowEvent::Resized(w, h) => gl_window.resize(w, h),
WindowEvent::KeyboardInput { input, .. } => {
if let Some(VirtualKeyCode::Escape) = input.virtual_keycode {
return ControlFlow::Break;
}
let mut fullscreen = true;
let mut running = true;
while running {
events_loop.poll_events(|event| {
println!("{:?}", event);
match event {
glutin::Event::WindowEvent { event, .. } => match event {
glutin::WindowEvent::CloseRequested => running = false,
glutin::WindowEvent::Resized(logical_size) => {
let dpi_factor = gl_window.get_hidpi_factor();
gl_window.resize(logical_size.to_physical(dpi_factor));
},
glutin::WindowEvent::KeyboardInput { input, .. } => {
match input.virtual_keycode {
Some(glutin::VirtualKeyCode::Escape) => running = false,
Some(glutin::VirtualKeyCode::F) => {
let monitor = if fullscreen {
None
} else {
Some(gl_window.get_current_monitor())
};
gl_window.set_fullscreen(monitor);
fullscreen = !fullscreen;
},
_ => (),
}
},
_ => (),
},
_ => (),
},
_ => (),
}
_ => ()
}
});

gl.draw_frame([0.0, 1.0, 0.0, 1.0]);
gl.draw_frame([1.0, 0.5, 0.7, 1.0]);
let _ = gl_window.swap_buffers();
ControlFlow::Continue
});
}
}
55 changes: 0 additions & 55 deletions examples/grabbing.rs

This file was deleted.

48 changes: 24 additions & 24 deletions examples/multiwindow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ fn main() {
let mut events_loop = glutin::EventsLoop::new();

let mut windows = std::collections::HashMap::new();
for _ in 0..3 {
let window = glutin::WindowBuilder::new();
for index in 0..3 {
let title = format!("Charming Window #{}", index + 1);
let window = glutin::WindowBuilder::new().with_title(title);
let context = glutin::ContextBuilder::new();
let gl_window = glutin::GlWindow::new(window, context, &events_loop).unwrap();
let _ = unsafe { gl_window.make_current() };
Expand All @@ -18,34 +19,33 @@ fn main() {
windows.insert(window_id, (gl_window, gl));
}

events_loop.run_forever(|event| {
println!("{:?}", event);
match event {
glutin::Event::WindowEvent { event, window_id } => match event {
glutin::WindowEvent::Resized(w, h) => {
windows[&window_id].0.resize(w, h)
},
glutin::WindowEvent::CloseRequested => {
if windows.remove(&window_id).is_some() {
println!("Window with ID {:?} has been closed", window_id);
if windows.is_empty() {
return glutin::ControlFlow::Break;
while !windows.is_empty() {
events_loop.poll_events(|event| {
println!("{:?}", event);
match event {
glutin::Event::WindowEvent { event, window_id } => match event {
glutin::WindowEvent::Resized(logical_size) => {
let gl_window = &windows[&window_id].0;
let dpi_factor = gl_window.get_hidpi_factor();
gl_window.resize(logical_size.to_physical(dpi_factor));
},
glutin::WindowEvent::CloseRequested => {
if windows.remove(&window_id).is_some() {
println!("Window with ID {:?} has been closed", window_id);
}
}
},
_ => (),
},
_ => (),
},
_ => (),
}
}
});

for (i, window) in windows.values().enumerate() {
let mut color = [0.0, 0.0, 0.0, 1.0];
color[i] = 1.0; // Color each of the three windows a different color.
for (index, window) in windows.values().enumerate() {
let mut color = [1.0, 0.5, 0.7, 1.0];
color.swap(0, index % 3);
let _ = unsafe { window.0.make_current() };
window.1.draw_frame(color);
let _ = window.0.swap_buffers();
}

glutin::ControlFlow::Continue
});
}
}
Loading

0 comments on commit cb05e03

Please sign in to comment.