Skip to content

Commit

Permalink
Auto merge of #1251 - csherratt:master, r=kvark
Browse files Browse the repository at this point in the history
Update to glutin 0.8, Winit 0.6

This will require gfx_window_glutin to be published.

I'm on linux and didn't get a chance to test the trianglell example.
  • Loading branch information
homu committed May 4, 2017
2 parents 3073c5f + 23ae748 commit 22b0d06
Show file tree
Hide file tree
Showing 21 changed files with 137 additions and 120 deletions.
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gfx_app"
version = "0.5.0"
version = "0.6.0"
description = "GFX example application framework"
homepage = "https://github.com/gfx-rs/gfx"
keywords = ["graphics", "gamedev"]
Expand All @@ -23,14 +23,14 @@ name = "gfx_app"
[dependencies]
log = "0.3"
env_logger = "0.4"
glutin = "0.7.1"
winit = "0.5.1"
glutin = "0.8.0"
winit = "0.6.0"
gfx_core = { path = "src/core", version = "0.7" }
gfx_corell = { path = "src/corell", version = "0.1" }
gfx = { path = "src/render", version = "0.15" }
gfx_macros = { path = "src/macros", version = "0.2" }
gfx_device_gl = { path = "src/backend/gl", version = "0.14" }
gfx_window_glutin = { path = "src/window/glutin", version = "0.15" }
gfx_window_glutin = { path = "src/window/glutin", version = "0.16" }

[dependencies.gfx_device_vulkan]
path = "src/backend/vulkan"
Expand Down Expand Up @@ -69,7 +69,7 @@ gfx_window_sdl = { path = "src/window/sdl", version = "0.6" }
[target.'cfg(windows)'.dependencies]
gfx_device_dx11 = { path = "src/backend/dx11", version = "0.6" }
# gfx_device_dx12ll = { path = "src/backend/dx12ll", version = "0.1" }
gfx_window_dxgi = { path = "src/window/dxgi", version = "0.7" }
gfx_window_dxgi = { path = "src/window/dxgi", version = "0.8" }

[[example]]
name = "blend"
Expand Down Expand Up @@ -142,7 +142,7 @@ rand = "0.3"
genmesh = "0.4"
noise = "0.1"
image = "0.13"
winit = "0.5"
winit = "0.6"

[target.x86_64-unknown-linux-gnu.dev-dependencies]
glfw = "0.12"
4 changes: 2 additions & 2 deletions examples/blend/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ impl<R: gfx::Resources> gfx_app::Application<R> for App<R> {
self.bundle.encode(encoder);
}

fn on(&mut self, event: winit::Event) {
fn on(&mut self, event: winit::WindowEvent) {
match event {
winit::Event::KeyboardInput(winit::ElementState::Pressed, _, Some(winit::VirtualKeyCode::B)) => {
winit::WindowEvent::KeyboardInput(winit::ElementState::Pressed, _, Some(winit::VirtualKeyCode::B), _) => {
self.id += 1;
if self.id as usize >= BLENDS.len() {
self.id = 0;
Expand Down
14 changes: 7 additions & 7 deletions examples/deferred/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use genmesh::generators::{SharedVertex, IndexedPolygon};
use noise::{Seed, perlin2};
use rand::Rng;
use std::time::{Instant};
use winit::{Event, VirtualKeyCode, WindowBuilder};
use winit::{WindowEvent, VirtualKeyCode, WindowBuilder};

// Remember to also change the constants in the shaders
const NUM_LIGHTS: usize = 250;
Expand Down Expand Up @@ -554,17 +554,17 @@ impl<R: gfx::Resources> gfx_app::Application<R> for App<R> {
self.blit.encode(encoder);
}

fn on(&mut self, event: Event) {
fn on(&mut self, event: WindowEvent) {
match event {
Event::KeyboardInput(_, _, Some(VirtualKeyCode::Key1)) =>
WindowEvent::KeyboardInput(_, _, Some(VirtualKeyCode::Key1), _) =>
self.debug_buf = Some(self.light.data.tex_pos.0.clone()),
Event::KeyboardInput(_, _, Some(VirtualKeyCode::Key2)) =>
WindowEvent::KeyboardInput(_, _, Some(VirtualKeyCode::Key2), _) =>
self.debug_buf = Some(self.light.data.tex_normal.0.clone()),
Event::KeyboardInput(_, _, Some(VirtualKeyCode::Key3)) =>
WindowEvent::KeyboardInput(_, _, Some(VirtualKeyCode::Key3), _) =>
self.debug_buf = Some(self.light.data.tex_diffuse.0.clone()),
Event::KeyboardInput(_, _, Some(VirtualKeyCode::Key4)) =>
WindowEvent::KeyboardInput(_, _, Some(VirtualKeyCode::Key4), _) =>
self.debug_buf = Some(self.depth_resource.clone()),
Event::KeyboardInput(_, _, Some(VirtualKeyCode::Key0)) =>
WindowEvent::KeyboardInput(_, _, Some(VirtualKeyCode::Key0), _) =>
self.debug_buf = None,
_ => (),
}
Expand Down
18 changes: 10 additions & 8 deletions examples/gamma/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ const QUAD: [Vertex; 4] = [
const CLEAR_COLOR: [f32; 4] = [0.5, 0.5, 0.5, 1.0];

pub fn main() {
let events_loop = glutin::EventsLoop::new();
let builder = glutin::WindowBuilder::new()
.with_title("Gamma example".to_string())
.with_dimensions(1024, 768)
.with_vsync();
let (window, mut device, mut factory, main_color, mut main_depth) =
gfx_window_glutin::init::<ColorFormat, DepthFormat>(builder);
gfx_window_glutin::init::<ColorFormat, DepthFormat>(builder, &events_loop);
let mut encoder: gfx::Encoder<_, _> = factory.create_command_buffer().into();
let pso = factory.create_pipeline_simple(
include_bytes!("shader/quad_150.glslv"),
Expand All @@ -63,18 +64,19 @@ pub fn main() {
out: main_color
};

'main: loop {
// loop over events
for event in window.poll_events() {
let mut running = true;
while running {
events_loop.poll_events(|glutin::Event::WindowEvent{window_id: _, event}| {
match event {
glutin::Event::KeyboardInput(_, _, Some(glutin::VirtualKeyCode::Escape)) |
glutin::Event::Closed => break 'main,
glutin::Event::Resized(_width, _height) => {
glutin::WindowEvent::KeyboardInput(_, _, Some(glutin::VirtualKeyCode::Escape), _) |
glutin::WindowEvent::Closed => running = false,
glutin::WindowEvent::Resized(_width, _height) => {
gfx_window_glutin::update_views(&window, &mut data.out, &mut main_depth);
},
_ => {},
}
}
});

// draw a frame
encoder.clear(&data.out, CLEAR_COLOR);
encoder.draw(&slice, &pso, &data);
Expand Down
25 changes: 15 additions & 10 deletions examples/performance/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ struct GL {


impl GFX {
fn new(builder: glutin::WindowBuilder, dimension: i16) -> Self {
fn new(builder: glutin::WindowBuilder, events_loop: &glutin::EventsLoop, dimension: i16) -> Self {
use gfx::traits::FactoryExt;

let (window, device, mut factory, main_color, _) =
gfx_window_glutin::init::<ColorFormat, DepthStencil>(builder);
gfx_window_glutin::init::<ColorFormat, DepthStencil>(builder, events_loop);
let encoder: gfx::Encoder<_,_> = factory.create_command_buffer().into();

let pso = factory.create_pipeline_simple(
Expand Down Expand Up @@ -185,7 +185,7 @@ impl Drop for GFX {


impl GL {
fn new(builder: glutin::WindowBuilder, dimension: i16) -> Self {
fn new(builder: glutin::WindowBuilder, events_loop: &glutin::EventsLoop, dimension: i16) -> Self {
fn compile_shader (gl:&Gl, src: &[u8], ty: GLenum) -> GLuint {
unsafe {
let shader = gl.CreateShader(ty);
Expand Down Expand Up @@ -213,7 +213,7 @@ impl GL {
}
};

let window = builder.build().unwrap();
let window = builder.build(events_loop).unwrap();
unsafe { window.make_current().unwrap() };
let gl = Gl::load_with(|s| window.get_proc_address(s) as *const _);

Expand Down Expand Up @@ -365,15 +365,16 @@ fn main() {

let count = ((count as f64).sqrt() / 2.) as i16;

let events_loop = glutin::EventsLoop::new();
let builder = glutin::WindowBuilder::new()
.with_title("Performance example".to_string())
.with_dimensions(800, 600)
.with_vsync();

let mut r: Box<Renderer>;
match mode.as_ref() {
"gfx" => r = Box::new(GFX::new(builder, count)),
"gl" => r = Box::new(GL::new(builder, count)),
"gfx" => r = Box::new(GFX::new(builder, &events_loop, count)),
"gl" => r = Box::new(GL::new(builder, &events_loop, count)),
x => {
panic!("{} is not a known mode", x)
}
Expand All @@ -398,13 +399,17 @@ fn main() {

println!("count is {}", count*count*4);

'main: loop {
for event in r.window().poll_events() {
let mut running = true;
loop {
events_loop.poll_events(|glutin::Event::WindowEvent{window_id: _, event}| {
match event {
glutin::Event::KeyboardInput(_, _, Some(glutin::VirtualKeyCode::Escape)) |
glutin::Event::Closed => break 'main,
glutin::WindowEvent::KeyboardInput(_, _, Some(glutin::VirtualKeyCode::Escape), _) |
glutin::WindowEvent::Closed => running = false,
_ => {},
}
});
if !running {
break;
}
r.render(&proj_view);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/shadow/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ impl<R, C> gfx_app::ApplicationBase<R, C> for App<R, C> where
Some(winit::VirtualKeyCode::Escape)
}

fn on(&mut self, event: winit::Event) {
fn on(&mut self, event: winit::WindowEvent) {
match event {
_ => () //TODO
}
Expand Down
20 changes: 12 additions & 8 deletions examples/triangle/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ const TRIANGLE: [Vertex; 3] = [
const CLEAR_COLOR: [f32; 4] = [0.1, 0.2, 0.3, 1.0];

pub fn main() {
let events_loop = glutin::EventsLoop::new();
let builder = glutin::WindowBuilder::new()
.with_title("Triangle example".to_string())
.with_dimensions(1024, 768)
.with_vsync();
let (window, mut device, mut factory, main_color, mut main_depth) =
gfx_window_glutin::init::<ColorFormat, DepthFormat>(builder);
gfx_window_glutin::init::<ColorFormat, DepthFormat>(builder, &events_loop);
let mut encoder: gfx::Encoder<_, _> = factory.create_command_buffer().into();
let pso = factory.create_pipeline_simple(
include_bytes!("shader/triangle_150.glslv"),
Expand All @@ -62,18 +63,21 @@ pub fn main() {
out: main_color
};

'main: loop {
// loop over events
for event in window.poll_events() {

let mut running = true;
while running {
// fetch events
events_loop.poll_events(|glutin::Event::WindowEvent{window_id: _, event}| {
match event {
glutin::Event::KeyboardInput(_, _, Some(glutin::VirtualKeyCode::Escape)) |
glutin::Event::Closed => break 'main,
glutin::Event::Resized(_width, _height) => {
glutin::WindowEvent::KeyboardInput(_, _, Some(glutin::VirtualKeyCode::Escape), _) |
glutin::WindowEvent::Closed => running = false,
glutin::WindowEvent::Resized(_width, _height) => {
gfx_window_glutin::update_views(&window, &mut data.out, &mut main_depth);
},
_ => {},
}
}
});

// draw a frame
encoder.clear(&data.out, CLEAR_COLOR);
encoder.draw(&slice, &pso, &data);
Expand Down
14 changes: 8 additions & 6 deletions examples/trianglell/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ const TRIANGLE: [Vertex; 6] = [
#[cfg(any(feature = "vulkan", target_os = "windows"))]
fn main() {
env_logger::init().unwrap();
let events_loop = winit::EventsLoop::new();
let window = winit::WindowBuilder::new()
.with_dimensions(1024, 768)
.with_title("triangle (Low Level)".to_string())
.build()
.build(&events_loop)
.unwrap();

// instantiate backend
Expand Down Expand Up @@ -367,14 +368,15 @@ fn main() {
}

//
'main: loop {
for event in window.poll_events() {
let mut running = true;
while running {
events_loop.poll_events(|winit::Event::WindowEvent{window_id: _, event}| {
match event {
winit::Event::KeyboardInput(_, _, Some(winit::VirtualKeyCode::Escape)) |
winit::Event::Closed => break 'main,
winit::WindowEvent::KeyboardInput(_, _, Some(winit::VirtualKeyCode::Escape), _) |
winit::WindowEvent::Closed => running = false,
_ => {},
}
}
});

general_queues[0].wait_idle(); // SLOW!

Expand Down
24 changes: 12 additions & 12 deletions examples/ubo_tilemap/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,42 +470,42 @@ impl<R: gfx::Resources> gfx_app::Application<R> for TileMap<R> {
encoder.draw(&self.tilemap_plane.slice, &self.pso, &self.tilemap_plane.params);
}

fn on(&mut self, event: winit::Event) {
fn on(&mut self, event: winit::WindowEvent) {
use winit::VirtualKeyCode as Key;
use winit::Event::KeyboardInput;
use winit::WindowEvent::KeyboardInput;
use winit::ElementState::Pressed;
let i = self.input.clone();
match event {
// zooming in/out
KeyboardInput(Pressed, _, Some(Key::Equals)) => {
KeyboardInput(Pressed, _, Some(Key::Equals), _) => {
self.input.distance -= i.move_amt;
}
KeyboardInput(Pressed, _, Some(Key::Minus)) => {
KeyboardInput(Pressed, _, Some(Key::Minus), _) => {
self.input.distance += i.move_amt;
}
// panning around
KeyboardInput(Pressed, _, Some(Key::Up)) => {
KeyboardInput(Pressed, _, Some(Key::Up), _) => {
self.input.y_pos -= i.move_amt;
}
KeyboardInput(Pressed, _, Some(Key::Down)) => {
KeyboardInput(Pressed, _, Some(Key::Down), _) => {
self.input.y_pos += i.move_amt;
}
KeyboardInput(Pressed, _, Some(Key::Left)) => {
KeyboardInput(Pressed, _, Some(Key::Left), _) => {
self.input.x_pos -= i.move_amt;
}
KeyboardInput(Pressed, _, Some(Key::Right)) => {
KeyboardInput(Pressed, _, Some(Key::Right), _) => {
self.input.x_pos += i.move_amt;
}
KeyboardInput(Pressed, _, Some(Key::W)) => {
KeyboardInput(Pressed, _, Some(Key::W), _) => {
self.apply_y_offset(i.offset_amt);
}
KeyboardInput(Pressed, _, Some(Key::S)) => {
KeyboardInput(Pressed, _, Some(Key::S), _) => {
self.apply_y_offset(-i.offset_amt);
}
KeyboardInput(Pressed, _, Some(Key::D)) => {
KeyboardInput(Pressed, _, Some(Key::D), _) => {
self.apply_x_offset(i.offset_amt);
}
KeyboardInput(Pressed, _, Some(Key::A)) => {
KeyboardInput(Pressed, _, Some(Key::A), _) => {
self.apply_x_offset(-i.offset_amt);
}
_ => ()
Expand Down
2 changes: 1 addition & 1 deletion src/backend/dx12ll/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ dxgi-sys = { git = "https://github.com/msiglreith/winapi-rs.git", branch = "gfx"
dxguid-sys = { git = "https://github.com/msiglreith/winapi-rs.git", branch = "gfx" }
comptr = { git = "https://github.com/msiglreith/comptr-rs.git" }
winapi = { git = "https://github.com/msiglreith/winapi-rs.git", branch = "gfx" }
winit = "0.5"
winit = "0.6"
2 changes: 1 addition & 1 deletion src/backend/vulkan/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ log = "0.3"
vk = "0.0"
vk-sys = { git = "https://github.com/sectopod/vulkano", branch = "bind" }
shared_library = "0.1"
winit = "0.5"
winit = "0.6"
gfx_core = { path = "../../core", version = "0.7" }
spirv-utils = { git = "https://github.com/msiglreith/spirv-utils.git", branch = "gfx" }
2 changes: 1 addition & 1 deletion src/backend/vulkanll/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ shared_library = "0.1"
gfx_corell = { path = "../../corell", version = "0.1.0" }
ash = "0.15.7"
spirv-utils = { git = "https://github.com/msiglreith/spirv-utils.git", branch = "gfx" }
winit = "0.5"
winit = "0.6"

[target.'cfg(windows)'.dependencies]
kernel32-sys = "0.2.2"
Loading

0 comments on commit 22b0d06

Please sign in to comment.