Module: RbSDL2::Timer
- Defined in:
- lib/rb_sdl2/timer.rb
Class Method Summary collapse
- .delay(ms) ⇒ Object
- .performance_count ⇒ Object
- .performance_frequency ⇒ Object
- .realtime ⇒ Object
- .ticks ⇒ Object
Class Method Details
.delay(ms) ⇒ Object
4 5 6 7 |
# File 'lib/rb_sdl2/timer.rb', line 4 def delay(ms) raise ArgumentError if ms < 0 ::SDL2.SDL_Delay(ms) end |
.performance_count ⇒ Object
11 |
# File 'lib/rb_sdl2/timer.rb', line 11 def performance_count = ::SDL2.SDL_GetPerformanceCounter |
.performance_frequency ⇒ Object
9 |
# File 'lib/rb_sdl2/timer.rb', line 9 def performance_frequency = ::SDL2.SDL_GetPerformanceFrequency |
.realtime ⇒ Object
13 14 15 16 17 |
# File 'lib/rb_sdl2/timer.rb', line 13 def realtime t = performance_count yield (performance_count - t).fdiv(performance_frequency) end |
.ticks ⇒ Object
19 |
# File 'lib/rb_sdl2/timer.rb', line 19 def ticks = ::SDL2.SDL_GetTicks |