aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock11
-rw-r--r--Cargo.toml1
-rw-r--r--src/bin/exuberantbovines.rs7
-rw-r--r--src/lib.rs5
4 files changed, 17 insertions, 7 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 5897394..384881e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5,6 +5,7 @@ dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"glium 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -564,6 +565,16 @@ dependencies = [
]
[[package]]
+name = "time"
+version = "0.1.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "user32-sys"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 5aa372f..1652bad 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,4 +11,5 @@ authors = ["bnewbold <bnewbold@robocracy.org>"]
glium = "0.*"
image = "0.*"
getopts = "^0.2"
+time = "0.1"
diff --git a/src/bin/exuberantbovines.rs b/src/bin/exuberantbovines.rs
index 799fff5..e07f28c 100644
--- a/src/bin/exuberantbovines.rs
+++ b/src/bin/exuberantbovines.rs
@@ -12,7 +12,6 @@ use glium::Surface;
mod cow_model;
struct ExuberantBovines {
- t: f64,
display: glium::Display,
program: glium::Program,
model_vertices: Vec<glium::VertexBuffer<cow_model::Vertex>>,
@@ -92,7 +91,6 @@ impl ExuberantBovines {
return ExuberantBovines {
display: display,
program: program,
- t: 0.0,
model_vertices: vec![face_vertices,
hide_vertices,
hoofs_vertices,
@@ -105,12 +103,11 @@ impl ExuberantBovines {
impl ExuberantHack for ExuberantBovines {
- fn draw_frame(&mut self) -> Result<(), String> {
+ fn draw_frame(&mut self, t: f64) -> Result<(), String> {
let indices = glium::index::NoIndices(glium::index::PrimitiveType::TrianglesList);
- self.t += 0.03;
- let z: f32 = 0.5 * self.t.sin() as f32;
+ let z: f32 = 0.5 * t.sin() as f32;
// Drawing Pipeline
let mut target = self.display.draw();
diff --git a/src/lib.rs b/src/lib.rs
index c73fc0c..f24c658 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -4,6 +4,7 @@ extern crate glium;
extern crate image;
extern crate getopts;
+extern crate time;
use std::env;
use std::process::exit;
@@ -14,7 +15,7 @@ use glium::{DisplayBuild, Display};
pub mod util;
pub trait ExuberantHack {
- fn draw_frame(&mut self) -> Result<(), String>;
+ fn draw_frame(&mut self, t: f64) -> Result<(), String>;
fn get_display(&self) -> &Display;
}
@@ -30,7 +31,7 @@ pub fn print_usage(opts: &Options) {
pub fn run(hack: &mut ExuberantHack, conf: &Matches) {
loop {
- hack.draw_frame().ok();
+ hack.draw_frame(time::precise_time_s()).ok();
for ev in hack.get_display().poll_events() {
match ev {
glium::glutin::Event::Closed => return,