Class: SFML::VideoMode
- Inherits:
-
Object
- Object
- SFML::VideoMode
- Defined in:
- lib/sfml/window/video_mode.rb
Overview
Video mode = (width, height, bits-per-pixel). Used when creating windows.
SFML::VideoMode.new(800, 600)
SFML::VideoMode.desktop_mode
Instance Attribute Summary collapse
-
#bits_per_pixel ⇒ Object
readonly
The width, height, bits per pixel components.
-
#height ⇒ Object
readonly
The width, height, bits per pixel components.
-
#width ⇒ Object
readonly
The width, height, bits per pixel components.
Class Method Summary collapse
-
.desktop_mode ⇒ Object
Returns the self.
-
.from_native(struct) ⇒ Object
Returns the self.
-
.fullscreen_modes ⇒ Object
All video modes the current display supports for true-fullscreen window creation, sorted from most to least pixels.
Instance Method Summary collapse
-
#initialize(width, height, bits_per_pixel = 32) ⇒ VideoMode
constructor
A new instance of VideoMode.
-
#size ⇒ Object
Returns the size.
-
#to_native ⇒ Object
Returns the to native.
-
#to_s ⇒ Object
(also: #inspect)
String representation for debugging.
-
#valid? ⇒ Boolean
Does the display actually support this mode at fullscreen? Always
truefor windowed-mode use (only fullscreen is constrained to the OS's allowed mode list).
Constructor Details
#initialize(width, height, bits_per_pixel = 32) ⇒ VideoMode
Returns a new instance of VideoMode.
10 11 12 13 14 15 |
# File 'lib/sfml/window/video_mode.rb', line 10 def initialize(width, height, bits_per_pixel = 32) @width = Integer(width) @height = Integer(height) @bits_per_pixel = Integer(bits_per_pixel) freeze end |
Instance Attribute Details
#bits_per_pixel ⇒ Object (readonly)
The width, height, bits per pixel components.
8 9 10 |
# File 'lib/sfml/window/video_mode.rb', line 8 def bits_per_pixel @bits_per_pixel end |
#height ⇒ Object (readonly)
The width, height, bits per pixel components.
8 9 10 |
# File 'lib/sfml/window/video_mode.rb', line 8 def height @height end |
#width ⇒ Object (readonly)
The width, height, bits per pixel components.
8 9 10 |
# File 'lib/sfml/window/video_mode.rb', line 8 def width @width end |
Class Method Details
.desktop_mode ⇒ Object
Returns the self.
18 19 20 |
# File 'lib/sfml/window/video_mode.rb', line 18 def self.desktop_mode from_native(C::Window.sfVideoMode_getDesktopMode) end |
.from_native(struct) ⇒ Object
Returns the self.
52 53 54 |
# File 'lib/sfml/window/video_mode.rb', line 52 def self.from_native(struct) # :nodoc: new(struct[:size][:x], struct[:size][:y], struct[:bits_per_pixel]) end |
.fullscreen_modes ⇒ Object
All video modes the current display supports for true-fullscreen window creation, sorted from most to least pixels. Filter by bpp or aspect ratio in Ruby as needed.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sfml/window/video_mode.rb', line 25 def self.fullscreen_modes count_buf = FFI::MemoryPointer.new(:size_t) array_ptr = C::Window.sfVideoMode_getFullscreenModes(count_buf) n = count_buf.read(:size_t) return [] if array_ptr.null? || n.zero? stride = C::Window::VideoMode.size Array.new(n) do |i| from_native(C::Window::VideoMode.new(array_ptr + i * stride)) end end |
Instance Method Details
#size ⇒ Object
Returns the size.
45 |
# File 'lib/sfml/window/video_mode.rb', line 45 def size = Vector2.new(@width, @height) |
#to_native ⇒ Object
Returns the to native.
57 58 59 60 61 62 63 |
# File 'lib/sfml/window/video_mode.rb', line 57 def to_native # :nodoc: C::Window::VideoMode.new.tap do |m| m[:size][:x] = @width m[:size][:y] = @height m[:bits_per_pixel] = @bits_per_pixel end end |
#to_s ⇒ Object Also known as: inspect
String representation for debugging.
48 |
# File 'lib/sfml/window/video_mode.rb', line 48 def to_s = "#<SFML::VideoMode #{@width}x#{@height}@#{@bits_per_pixel}>" |