Use std::time instead of the deprecated time crate

This commit is contained in:
Joonas Javanainen 2016-08-07 19:58:19 +03:00
parent 9c56e48140
commit d6456d50fa
5 changed files with 6 additions and 12 deletions

View File

@ -25,9 +25,6 @@ path = "imgui-sys"
[build-dependencies] [build-dependencies]
gcc = "0.3" gcc = "0.3"
[dev-dependencies]
time = "0.1"
[dev-dependencies.glium] [dev-dependencies.glium]
version = "0.15" version = "0.15"
features = ["glutin"] features = ["glutin"]

View File

@ -2,7 +2,6 @@
extern crate glium; extern crate glium;
#[macro_use] #[macro_use]
extern crate imgui; extern crate imgui;
extern crate time;
use imgui::*; use imgui::*;

View File

@ -4,13 +4,13 @@ use glium::glutin;
use glium::glutin::{ElementState, Event, MouseButton, MouseScrollDelta, VirtualKeyCode, TouchPhase}; use glium::glutin::{ElementState, Event, MouseButton, MouseScrollDelta, VirtualKeyCode, TouchPhase};
use imgui::{ImGui, Ui, ImGuiKey}; use imgui::{ImGui, Ui, ImGuiKey};
use imgui::glium_renderer::Renderer; use imgui::glium_renderer::Renderer;
use time::SteadyTime; use std::time::Instant;
pub struct Support { pub struct Support {
display: GlutinFacade, display: GlutinFacade,
imgui: ImGui, imgui: ImGui,
renderer: Renderer, renderer: Renderer,
last_frame: SteadyTime, last_frame: Instant,
mouse_pos: (i32, i32), mouse_pos: (i32, i32),
mouse_pressed: (bool, bool, bool), mouse_pressed: (bool, bool, bool),
mouse_wheel: f32, mouse_wheel: f32,
@ -49,7 +49,7 @@ impl Support {
display: display, display: display,
imgui: imgui, imgui: imgui,
renderer: renderer, renderer: renderer,
last_frame: SteadyTime::now(), last_frame: Instant::now(),
mouse_pos: (0, 0), mouse_pos: (0, 0),
mouse_pressed: (false, false, false), mouse_pressed: (false, false, false),
mouse_wheel: 0.0 mouse_wheel: 0.0
@ -65,9 +65,9 @@ impl Support {
} }
pub fn render<F: FnMut(&Ui)>(&mut self, clear_color: (f32, f32, f32, f32), mut run_ui: F) { pub fn render<F: FnMut(&Ui)>(&mut self, clear_color: (f32, f32, f32, f32), mut run_ui: F) {
let now = SteadyTime::now(); let now = Instant::now();
let delta = now - self.last_frame; let delta = now - self.last_frame;
let delta_f = delta.num_nanoseconds().unwrap() as f32 / 1_000_000_000.0; let delta_s = delta.as_secs() as f32 + delta.subsec_nanos() as f32 / 1_000_000_000.0;
self.last_frame = now; self.last_frame = now;
self.update_mouse(); self.update_mouse();
@ -80,7 +80,7 @@ impl Support {
let size_points = window.get_inner_size_points().unwrap(); let size_points = window.get_inner_size_points().unwrap();
let size_pixels = window.get_inner_size_pixels().unwrap(); let size_pixels = window.get_inner_size_pixels().unwrap();
let ui = self.imgui.frame(size_points, size_pixels, delta_f); let ui = self.imgui.frame(size_points, size_pixels, delta_s);
run_ui(&ui); run_ui(&ui);

View File

@ -2,7 +2,6 @@
extern crate glium; extern crate glium;
#[macro_use] #[macro_use]
extern crate imgui; extern crate imgui;
extern crate time;
use self::support::Support; use self::support::Support;

View File

@ -2,7 +2,6 @@
extern crate glium; extern crate glium;
#[macro_use] #[macro_use]
extern crate imgui; extern crate imgui;
extern crate time;
use imgui::*; use imgui::*;
use std::iter::repeat; use std::iter::repeat;