Skip to content

Commit

Permalink
Merge pull request PistonDevelopers#272 from cmr/master
Browse files Browse the repository at this point in the history
Fix the build and ignore some instability warnings
  • Loading branch information
csherratt committed Jan 18, 2015
2 parents a31e956 + 6b5c2fe commit 5bdbc68
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 76 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ default = ["glfw-sys"]
[dependencies]
semver = "*"
log = "*"
bitflags = "*"
libc = "*"

[dependencies.glfw-sys]
git = "https://github.com/servo/glfw"
Expand Down
8 changes: 4 additions & 4 deletions examples/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ extern crate glfw;
use glfw::{Action, Context, Key};

fn main() {
let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

let (window, events) = glfw.create_window(300, 300, "Clipboard Test", glfw::WindowMode::Windowed)
let (mut window, events) = glfw.create_window(300, 300, "Clipboard Test", glfw::WindowMode::Windowed)
.expect("Failed to create GLFW window.");

window.set_key_polling(true);
Expand All @@ -30,7 +30,7 @@ fn main() {
while !window.should_close() {
glfw.poll_events();
for (_, event) in glfw::flush_messages(&events) {
handle_window_event(&window, event);
handle_window_event(&mut window, event);
}
}
}
Expand All @@ -41,7 +41,7 @@ static NATIVE_MOD: glfw::Modifiers = glfw::Super;
#[cfg(not(target_os = "macos"))]
static NATIVE_MOD: glfw::Modifiers = glfw::Control;

fn handle_window_event(window: &glfw::Window, event: glfw::WindowEvent) {
fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
match event {
glfw::WindowEvent::Key(key, _, action, mods) => {
if action == Action::Press {
Expand Down
8 changes: 4 additions & 4 deletions examples/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ extern crate glfw;
use glfw::{Action, Context, CursorMode, Key};

fn main() {
let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

let (window, events) = glfw.create_window(800, 600, "Hello, I am a window.", glfw::WindowMode::Windowed)
let (mut window, events) = glfw.create_window(800, 600, "Hello, I am a window.", glfw::WindowMode::Windowed)
.expect("Failed to create GLFW window.");

window.set_cursor_mode(CursorMode::Disabled);
Expand All @@ -32,12 +32,12 @@ fn main() {
while !window.should_close() {
glfw.poll_events();
for (_, event) in glfw::flush_messages(&events) {
handle_window_event(&window, event);
handle_window_event(&mut window, event);
}
}
}

fn handle_window_event(window: &glfw::Window, event: glfw::WindowEvent) {
fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
match event {
glfw::WindowEvent::CursorPos(xpos, ypos) => println!("Cursor position: ({:?}, {:?})", xpos, ypos),
glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => window.set_should_close(true),
Expand Down
4 changes: 2 additions & 2 deletions examples/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ extern crate glfw;
use glfw::Context;

fn main() {
let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

glfw.window_hint(glfw::WindowHint::Visible(true));

let (window, _) = glfw.create_window(640, 480, "Defaults", glfw::WindowMode::Windowed)
let (mut window, _) = glfw.create_window(640, 480, "Defaults", glfw::WindowMode::Windowed)
.expect("Failed to create GLFW window.");

window.make_current();
Expand Down
2 changes: 1 addition & 1 deletion examples/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extern crate glfw;
use std::cell::Cell;

fn main() {
let glfw = glfw::init(Some(
let mut glfw = glfw::init(Some(
glfw::Callback {
f: error_callback as fn(glfw::Error, String, &Cell<usize>),
data: Cell::new(0),
Expand Down
8 changes: 4 additions & 4 deletions examples/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ extern crate glfw;
use glfw::{Action, Context, Key};

fn main() {
let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

glfw.window_hint(glfw::WindowHint::Resizable(true));

let (window, events) = glfw.create_window(800, 600, "Hello, I am a window.", glfw::WindowMode::Windowed)
let (mut window, events) = glfw.create_window(800, 600, "Hello, I am a window.", glfw::WindowMode::Windowed)
.expect("Failed to create GLFW window.");

window.set_sticky_keys(true);
Expand Down Expand Up @@ -53,12 +53,12 @@ fn main() {
while !window.should_close() {
glfw.poll_events();
for event in glfw::flush_messages(&events) {
handle_window_event(&window, event);
handle_window_event(&mut window, event);
}
}
}

fn handle_window_event(window: &glfw::Window, (time, event): (f64, glfw::WindowEvent)) {
fn handle_window_event(window: &mut glfw::Window, (time, event): (f64, glfw::WindowEvent)) {
match event {
glfw::WindowEvent::Pos(x, y) => window.set_title(format!("Time: {:?}, Window pos: ({:?}, {:?})", time, x, y).as_slice()),
glfw::WindowEvent::Size(w, h) => window.set_title(format!("Time: {:?}, Window size: ({:?}, {:?})", time, w, h).as_slice()),
Expand Down
8 changes: 4 additions & 4 deletions examples/monitors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ extern crate glfw;
use glfw::{Action, Context, Key};

fn main() {
let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

glfw.with_connected_monitors(|monitors| {
for monitor in monitors.iter() {
println!("{:?}: {:?}", monitor.get_name(), monitor.get_video_mode());
}
});

let (window, events) = glfw.with_primary_monitor(|m| {
let (mut window, events) = glfw.with_primary_monitor(|m| {
glfw.create_window(300, 300, "Hello this is window",
m.map_or(glfw::WindowMode::Windowed, |m| glfw::WindowMode::FullScreen(m)))
}).expect("Failed to create GLFW window.");
Expand All @@ -37,12 +37,12 @@ fn main() {
while !window.should_close() {
glfw.poll_events();
for (_, event) in glfw::flush_messages(&events) {
handle_window_event(&window, event);
handle_window_event(&mut window, event);
}
}
}

fn handle_window_event(window: &glfw::Window, event: glfw::WindowEvent) {
fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
match event {
glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => {
window.set_should_close(true)
Expand Down
8 changes: 4 additions & 4 deletions examples/render_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use glfw::{Action, Context, Key};
use std::thread::Builder;

fn main() {
let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

let (mut window, events) = glfw.create_window(300, 300, "Hello this is window", glfw::WindowMode::Windowed)
.expect("Failed to create GLFW window.");
Expand All @@ -41,7 +41,7 @@ fn main() {
while !window.should_close() {
glfw.poll_events();
for (_, event) in glfw::flush_messages(&events) {
handle_window_event(&window, event);
handle_window_event(&mut window, event);
}
}

Expand All @@ -52,7 +52,7 @@ fn main() {
let _ = render_task_done;
}

fn render(context: glfw::RenderContext, finish: Receiver<()>) {
fn render(mut context: glfw::RenderContext, finish: Receiver<()>) {
context.make_current();
loop {
// Check if the rendering should stop.
Expand All @@ -67,7 +67,7 @@ fn render(context: glfw::RenderContext, finish: Receiver<()>) {
glfw::make_context_current(None);
}

fn handle_window_event(window: &glfw::Window, event: glfw::WindowEvent) {
fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
match event {
glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => {
window.set_should_close(true)
Expand Down
8 changes: 4 additions & 4 deletions examples/title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ extern crate glfw;
use glfw::{Action, Context, Key};

fn main() {
let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

let (window, events) = glfw.create_window(400, 400, "English 日本語 русский язык 官話", glfw::WindowMode::Windowed)
let (mut window, events) = glfw.create_window(400, 400, "English 日本語 русский язык 官話", glfw::WindowMode::Windowed)
.expect("Failed to create GLFW window.");

window.set_key_polling(true);
Expand All @@ -30,12 +30,12 @@ fn main() {
while !window.should_close() {
glfw.poll_events();
for (_, event) in glfw::flush_messages(&events) {
handle_window_event(&window, event);
handle_window_event(&mut window, event);
}
}
}

fn handle_window_event(window: &glfw::Window, event: glfw::WindowEvent) {
fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
match event {
glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => {
window.set_should_close(true)
Expand Down
8 changes: 4 additions & 4 deletions examples/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ extern crate glfw;
use glfw::{Action, Context, Key};

fn main() {
let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();

let (window, events) = glfw.create_window(300, 300, "Hello this is window", glfw::WindowMode::Windowed)
let (mut window, events) = glfw.create_window(300, 300, "Hello this is window", glfw::WindowMode::Windowed)
.expect("Failed to create GLFW window.");

window.set_key_polling(true);
Expand All @@ -29,12 +29,12 @@ fn main() {
while !window.should_close() {
glfw.poll_events();
for (_, event) in glfw::flush_messages(&events) {
handle_window_event(&window, event);
handle_window_event(&mut window, event);
}
}
}

fn handle_window_event(window: &glfw::Window, event: glfw::WindowEvent) {
fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
match event {
glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => {
window.set_should_close(true)
Expand Down
Loading

0 comments on commit 5bdbc68

Please sign in to comment.