Class: RbSDL2::Display
Defined Under Namespace
Modules: DisplayOrientation
Class Method Summary
collapse
Instance Method Summary
collapse
#flipped_landscape?, #flipped_portrait?, #landscape?, #portrait?
Constructor Details
#initialize(num) ⇒ Display
Returns a new instance of Display.
11
12
13
|
# File 'lib/rb_sdl2/display.rb', line 11
def initialize(num)
@num = num
end
|
Class Method Details
.displays ⇒ Object
4
5
6
7
8
|
# File 'lib/rb_sdl2/display.rb', line 4
def displays
count = ::SDL.GetNumVideoDisplays
raise RbSDL2Error if count < 0
count.times.map { |num| Display.new(num) }
end
|
Instance Method Details
#bounds ⇒ Object
15
16
17
18
19
20
|
# File 'lib/rb_sdl2/display.rb', line 15
def bounds
rect = Rect.new
err = ::SDL.GetDisplayBounds(index, rect)
raise RbSDL2Error if err < 0
rect.to_a
end
|
#closest_display_mode(**display_mode) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/rb_sdl2/display.rb', line 24
def closest_display_mode(**display_mode)
mode ||= DisplayMode.new(**display_mode)
closest = DisplayMode.new
err = ::SDL.GetClosestDisplayMode(self, mode, closest)
raise RbSDL2Error if err.null?
closest
end
|
#current_display_mode ⇒ Object
36
37
38
39
40
41
|
# File 'lib/rb_sdl2/display.rb', line 36
def current_display_mode
obj = DisplayMode.new
err = ::SDL.GetCurrentDisplayMode(index, obj)
raise RbSDL2Error if err < 0
obj
end
|
#desktop_display_mode ⇒ Object
43
44
45
46
47
48
|
# File 'lib/rb_sdl2/display.rb', line 43
def desktop_display_mode
obj = DisplayMode.new
err = ::SDL.GetDesktopDisplayMode(index, obj)
raise RbSDL2Error if err < 0
obj
end
|
#display_modes ⇒ Object
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/rb_sdl2/display.rb', line 50
def display_modes
num = ::SDL.GetNumDisplayModes(index)
raise RbSDL2Error if num < 0
num.times.map do |mode_index|
obj = DisplayMode.new
err = ::SDL.GetDisplayMode(index, mode_index, obj)
raise RbSDL2Error if err < 0
obj
end
end
|
#dpi ⇒ Object
ディスプレイピクセルの斜め、水平、垂直方向の DPI を配列で戻す。
62
63
64
65
66
67
|
# File 'lib/rb_sdl2/display.rb', line 62
def dpi
d_h_v_dpi = Array.new(3) { ::FFI::MemoryPointer.new(:float) }
err = ::SDL.GetDisplayDPI(index, *d_h_v_dpi)
raise RbSDL2Error if err < 0
d_h_v_dpi.map { |v| v.read_float }
end
|
#index ⇒ Object
Also known as:
to_int
69
|
# File 'lib/rb_sdl2/display.rb', line 69
def index = @num
|
#inspect ⇒ Object
72
73
74
|
# File 'lib/rb_sdl2/display.rb', line 72
def inspect
"#<#{self.class.name} name=#{name.inspect} bounds=#{bounds} dpi=#{dpi}>"
end
|
#name ⇒ Object
Also known as:
to_s
76
77
78
79
80
|
# File 'lib/rb_sdl2/display.rb', line 76
def name
ptr = ::SDL.GetDisplayName(index)
raise RbSDL2Error if ptr.null?
SDL.ptr_to_str(ptr)
end
|
#orientation ⇒ Object
83
|
# File 'lib/rb_sdl2/display.rb', line 83
def orientation = ::SDL.GetDisplayOrientation(index)
|
#usable_bounds ⇒ Object
96
97
98
99
100
101
|
# File 'lib/rb_sdl2/display.rb', line 96
def usable_bounds
rect = Rect.new
err = ::SDL.GetDisplayUsableBounds(index, rect)
raise RbSDL2Error if err < 0
rect.to_a
end
|