Class: Engine::VideoMode

Inherits:
Object
  • Object
show all
Defined in:
lib/engine/video_mode.rb

Overview

Class Method Summary collapse

Class Method Details

.current_video_mode(monitor: Window.primary_monitor) ⇒ Object



8
9
10
# File 'lib/engine/video_mode.rb', line 8

def current_video_mode(monitor: Window.primary_monitor)
  video_mode_helper(GLFW.GetVideoMode(monitor), 0)
end

.get_video_modes(monitor: Window.primary_monitor) ⇒ Object

Returns an array of video modes



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/engine/video_mode.rb', line 13

def get_video_modes(monitor: Window.primary_monitor)
  count_pointer = ' ' * Fiddle::SIZEOF_INT
  modes_pointer = GLFW.GetVideoModes(monitor, count_pointer)
  count = count_pointer.unpack1('L')

  supported_video_modes = []
  count.times do |i|
    supported_video_modes << video_mode_helper(modes_pointer, i)
  end
  supported_video_modes
end


25
26
27
28
29
30
# File 'lib/engine/video_mode.rb', line 25

def print_video_mode(mode)
  GLFW::GLFWvidmode.members.map(&:to_sym).map do |attr|
    puts "#{attr}: #{mode.send(attr)}"
  end
  puts
end

.video_mode_helper(mode_pointer, index) ⇒ Object



32
33
34
# File 'lib/engine/video_mode.rb', line 32

def video_mode_helper(mode_pointer, index)
  GLFW::GLFWvidmode.new(mode_pointer + index * GLFW::GLFWvidmode.size)
end