Module: RbSDL2::Timer

Defined in:
lib/rb_sdl2/timer.rb

Class Method Summary collapse

Class Method Details

.delay(ms) ⇒ Object

Raises:

  • (ArgumentError)


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_countObject



11
# File 'lib/rb_sdl2/timer.rb', line 11

def performance_count = ::SDL2.SDL_GetPerformanceCounter

.performance_frequencyObject



9
# File 'lib/rb_sdl2/timer.rb', line 9

def performance_frequency = ::SDL2.SDL_GetPerformanceFrequency

.realtimeObject



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

.ticksObject



19
# File 'lib/rb_sdl2/timer.rb', line 19

def ticks = ::SDL2.SDL_GetTicks