mirror of
https://github.com/encounter/rust-sdl2.git
synced 2026-07-10 21:18:41 -07:00
Added timer functions, as this makes testing easier, until I get to doing events
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -10,5 +10,6 @@
|
||||
pub use sdl::*;
|
||||
pub mod rect;
|
||||
pub mod video;
|
||||
pub mod timer;
|
||||
pub mod render;
|
||||
pub mod sdl;
|
||||
|
||||
@@ -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) }
|
||||
}
|
||||
Reference in New Issue
Block a user