Class: SDL2::Display::Modes

Inherits:
Object
  • Object
show all
Defined in:
lib/sdl2/display/modes.rb

Instance Method Summary collapse

Constructor Details

#initialize(for_display) ⇒ Modes

TODO: Consider converting this into some kind of enumerator?



9
10
11
# File 'lib/sdl2/display/modes.rb', line 9

def initialize(for_display)
  @for_display = for_display
end

Instance Method Details

#[](index) ⇒ Object

TODO: Probably leaks memory.. WeakRef cache?



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sdl2/display/modes.rb', line 18

def [](index)
  if (idx = index.to_i) < count
    dm_buffer = SDL2::Display::Mode.new
    if SDL2.get_display_mode(@for_display.id, idx, dm_buffer) == 0
      return dm_buffer
    else
      dm_buffer.pointer.free
    end
  else
    return nil
  end
end

#countObject



13
14
15
# File 'lib/sdl2/display/modes.rb', line 13

def count
  SDL2.get_num_display_modes(@for_display.id)
end

#firstObject



31
32
33
# File 'lib/sdl2/display/modes.rb', line 31

def first
  self[0]
end