Class: SDL2::Display
- Inherits:
-
Object
- Object
- SDL2::Display
- Defined in:
- lib/sdl2/display.rb,
lib/sdl2/display/mode.rb,
lib/sdl2/display/modes.rb
Overview
Abstract representation of what SDL calls a “Display”
Defined Under Namespace
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #bounds ⇒ Object
- #bounds! ⇒ Object
- #closest_display_mode(wanted) ⇒ Object
- #closest_display_mode!(wanted) ⇒ Object
-
#initialize(display_id) ⇒ Display
constructor
A new instance of Display.
- #modes ⇒ Object
Constructor Details
#initialize(display_id) ⇒ Display
Returns a new instance of Display.
12 13 14 15 |
# File 'lib/sdl2/display.rb', line 12 def initialize(display_id) @id = display_id.to_i # It should be an integer. end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/sdl2/display.rb', line 10 def id @id end |
Class Method Details
.[](display_id) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/sdl2/display.rb', line 22 def self.[](display_id) if (idx = display_id.to_i) < count return Display.new(display_id) else return nil end end |
.count ⇒ Object
30 31 32 |
# File 'lib/sdl2/display.rb', line 30 def self.count SDL2.get_num_video_displays() end |
.count! ⇒ Object
34 35 36 37 38 |
# File 'lib/sdl2/display.rb', line 34 def self.count! total = count SDL2.raise_error_if total < 0 return total end |
.first ⇒ Object
40 41 42 |
# File 'lib/sdl2/display.rb', line 40 def self.first self[0] end |
Instance Method Details
#bounds ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/sdl2/display.rb', line 55 def bounds rect = SDL2::Rect.new if SDL2.get_display_bounds(@id, rect) == 0 return rect else rect.pointer.free return nil end end |
#bounds! ⇒ Object
65 66 67 68 69 |
# File 'lib/sdl2/display.rb', line 65 def bounds! rect = bounds() SDL2.raise_error_if rect.nil? return rect end |
#closest_display_mode(wanted) ⇒ Object
44 45 46 47 |
# File 'lib/sdl2/display.rb', line 44 def closest_display_mode(wanted) closest = SDL2::Display::Mode.new # Make a new structure. return SDL2.get_closest_display_mode(@id, wanted, closest) end |
#closest_display_mode!(wanted) ⇒ Object
49 50 51 52 53 |
# File 'lib/sdl2/display.rb', line 49 def closest_display_mode!(wanted) found = closest_display_mode(wanted) SDL2.raise_error_if(found.nil?) return found end |