Added timer functions, as this makes testing easier, until I get to doing events

This commit is contained in:
Tony Aldridge
2013-08-19 20:34:13 +01:00
parent 910d9d56c8
commit 5c6ac86af3
3 changed files with 31 additions and 0 deletions
+1
View File
@@ -16,5 +16,6 @@ pub fn main() {
renderer.set_draw_color(sdl2::video::RGB(255, 0, 0));
renderer.clear();
renderer.present();
sdl2::timer::delay(5000);
sdl2::quit();
}
+1
View File
@@ -10,5 +10,6 @@
pub use sdl::*;
pub mod rect;
pub mod video;
pub mod timer;
pub mod render;
pub mod sdl;
+29
View File
@@ -0,0 +1,29 @@
pub mod ll {
use std::libc::{uint32_t, uint64_t};
extern "C" {
//SDL_timer.h
pub fn SDL_GetTicks() -> uint32_t;
pub fn SDL_GetPerformanceCounter() -> uint64_t;
pub fn SDL_GetPerformanceFrequency() -> uint64_t;
pub fn SDL_Delay(ms: uint32_t);
//TODO: Figure out what to do with the timer callback functions
}
}
pub fn get_ticks() -> uint {
unsafe { ll::SDL_GetTicks() as uint }
}
pub fn get_performance_counter() -> u64 {
unsafe { ll::SDL_GetPerformanceCounter() }
}
pub fn get_performance_frequency() -> u64 {
unsafe { ll::SDL_GetPerformanceFrequency() }
}
pub fn delay(ms: uint) {
unsafe { ll::SDL_Delay(ms as u32) }
}