class SDL2::Display
Abstract representation of what SDL calls a “Display”
Attributes
id[R]
Every display has an id, an index.
Public Class Methods
[](display_id)
click to toggle source
Get the display instance for index display_id
# File lib/sdl2/display.rb, line 24 def self.[](display_id) if (idx = display_id.to_i) < count return Display.new(display_id) else return nil end end
count()
click to toggle source
Get the number of displays
# File lib/sdl2/display.rb, line 33 def self.count SDL2.get_num_video_displays!() end
first()
click to toggle source
Return the first display
# File lib/sdl2/display.rb, line 43 def self.first self[0] end
new(display_id)
click to toggle source
Initialize a new display for index display_id
# File lib/sdl2/display.rb, line 14 def initialize(display_id) @id = display_id.to_i # It should be an integer. end
num()
click to toggle source
An alias for count, the number of displays
# File lib/sdl2/display.rb, line 38 def self.num self.count end
Public Instance Methods
bounds()
click to toggle source
Returns the bounds
# File lib/sdl2/display.rb, line 62 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!()
click to toggle source
# File lib/sdl2/display.rb, line 72 def bounds! rect = bounds() SDL2.raise_error_if rect.nil? return rect end
closest_display_mode(wanted)
click to toggle source
Retrieve a display mode closest to a requested ideal. May return nil
# File lib/sdl2/display.rb, line 49 def closest_display_mode(wanted) closest = SDL2::Display::Mode.new # Make a new structure. return SDL2.get_closest_display_mode(@id, wanted, closest) end
current_display_mode()
click to toggle source
Get the current display mode
# File lib/sdl2/display.rb, line 55 def current_display_mode display_mode = SDL2::Display::Mode.new SDL2.get_current_display_mode!(@id, display_mode) display_mode end
modes()
click to toggle source
Every display has many modes
# File lib/sdl2/display.rb, line 19 def modes @modes ||= Modes.new(self) end