Skip to content

Commit

Permalink
Use () instead of libc::void
Browse files Browse the repository at this point in the history
Closes PistonDevelopers#1000

- Removed dependency on libc in pistoncore-window
- Updated from `sleep_ms` to `sleep` in pistoncore-event_loop
- Bumped to 0.16.0
  • Loading branch information
bvssvni committed Nov 21, 2015
1 parent 7441632 commit 57702f2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "piston"
version = "0.15.1"
version = "0.16.0"
authors = [
"bvssvni <bvssvni@gmail.com>",
"Coeuvre <coeuvre@gmail.com>",
Expand Down Expand Up @@ -33,8 +33,8 @@ version = "0.8.0"

[dependencies.pistoncore-window]
path = "src/window"
version = "0.13.0"
version = "0.14.0"

[dependencies.pistoncore-event_loop]
path = "src/event_loop"
version = "0.15.0"
version = "0.16.0"
4 changes: 2 additions & 2 deletions src/event_loop/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "pistoncore-event_loop"
version = "0.15.0"
version = "0.16.0"
authors = [
"bvssvni <bvssvni@gmail.com>",
"Coeuvre <coeuvre@gmail.com>",
Expand All @@ -22,7 +22,7 @@ path = "src/lib.rs"

[dependencies.pistoncore-window]
path = "../window"
version = "0.13.0"
version = "0.14.0"

[dependencies.pistoncore-input]
path = "../input"
Expand Down
13 changes: 8 additions & 5 deletions src/event_loop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
#![deny(missing_docs)]
#![deny(missing_copy_implementations)]

extern crate time;
extern crate window;
extern crate input;
extern crate viewport;
extern crate time;

use std::cell::RefCell;
use std::rc::Rc;
use std::thread::sleep_ms;
use std::thread::sleep;
use std::time::Duration;
use std::cmp;
use std::marker::PhantomData;
use window::Window;
Expand Down Expand Up @@ -170,8 +171,10 @@ pub struct WindowEvents<W, E>

static BILLION: u64 = 1_000_000_000;

fn ns_to_ms(ns: u64) -> u32 {
(ns / 1_000_000) as u32
fn ns_to_duration(ns: u64) -> Duration {
let secs = ns / BILLION;
let nanos = (ns % BILLION) as u32;
Duration::new(secs, nanos)
}

/// The default updates per second.
Expand Down Expand Up @@ -303,7 +306,7 @@ impl<W, E> Iterator for WindowEvents<W, E>
let seconds = ((next_event - current_time) as f64) / (BILLION as f64);
return Some(EventMap::idle(IdleArgs { dt: seconds }))
}
sleep_ms(ns_to_ms(next_event - current_time));
sleep(ns_to_duration(next_event - current_time));
State::UpdateLoop(Idle::No)
} else if next_event == next_frame {
State::Render
Expand Down
3 changes: 1 addition & 2 deletions src/window/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "pistoncore-window"
version = "0.13.0"
version = "0.14.0"
authors = [
"bvssvni <bvssvni@gmail.com>",
"Coeuvre <coeuvre@gmail.com>"
Expand All @@ -22,5 +22,4 @@ path = "../input"
version = "0.8.0"

[dependencies]
libc = "0.2"
shader_version = "0.2.1"
3 changes: 1 addition & 2 deletions src/window/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@

//! Window abstraction

extern crate libc;
extern crate input;
extern crate shader_version;

use shader_version::OpenGL;
use input::Input;

/// The type of an OpenGL function address.
pub type ProcAddress = *const libc::c_void;
pub type ProcAddress = *const ();

/// Size in pixels.
#[derive(Debug, Copy, Clone)]
Expand Down

0 comments on commit 57702f2

Please sign in to comment.