A Monitor represents a physical monitor connected to the system.
Returns the primary monitor, which is inferred by GLFW as the window that includes the task bar.
monitor = CrystGLFW::Monitor.primary
puts "Monitor #{monitor.name} is the primary monitor."
NOTE This method must be called from within a CrystGLFW#run
block definition.
Returns all monitors currently connected to the system as an Array.
monitors = CrystGLFW::Monitor.all
monitors.each { |m| puts m.name } # Prints out the name of each connected monitor.
NOTE This method must be called from within a CrystGLFW#run
block definition.
Defines the behavior that gets triggered when a monitor is either connected or disconnected.
monitor = CrystGLFW::Monitor.primary
monitor.on_toggle_connection do |event|
if event.connected?
puts "Welcome back, #{event.monitor.name}!"
else
puts "Farewell, #{event.monitor.name}."
end
end
def
gamma=(gamma : Number)
#
Alternate syntax for #set_gamma
.
This method accepts the following arguments:
- gamma, the exponent used to generate the new gamma ramp.
NOTE This method must be called inside a CrystGLFW#run
block definition.
Returns the monitor's current gamma ramp.
NOTE This method must be called inside a CrystGLFW#run
block definition.
Returns the monitor's name, as set by the manufacturer.
# Retrieve the primary monitor.
monitor = CrystGLFW::Monitor.primary
# Print out the name of the monitor.
puts "The name of the primary monitor is #{monitor.name}"
NOTE This method must be called from within a CrystGLFW#run
block definition.
def
physical_size : NamedTuple()
#
Returns the physical size of the monitor in millimeters.
# Retrieve the primary monitor.
monitor = CrystGLFW::Monitor.primary
# Calculate the area of the monitor using its physical size.
monitor_area = monitor.physical_size[:width] * monitor.physical_size[:height]
# Print the area of the monitor in millimeters.
puts "The area of the monitor is #{monitor_area} millimeters squared."
NOTE This method must be called from within a CrystGLFW#run
block definition.
def
position : NamedTuple()
#
Returns the position of the upper-left corner of the monitor in screen coordinates relative to the virtual screen.
# Retrieve all monitors.
monitors = CrystGLFW::Monitors.all
# Find the monitor that is furthest to the left.
leftmost_monitor = monitors.min_by { |monitor| monitor.position[:x] }
NOTE This method must be called from within a CrystGLFW#run
block definition.
def
set_gamma(gamma : Number)
#
Generates a gamma ramp from the given exponent and sets it as the monitor's gamma ramp.
This method accepts the following arguments:
- gamma, the exponent used to generate the new gamma ramp.
NOTE This method must be called inside a CrystGLFW#run
block definition.
Sets the monitor's gamma ramp to the given gamma ramp.
Returns the monitor's current video mode.
# Retrieve the primary monitor.
monitor = CrystGLFW::Monitor.primary
current_video_mode = monitor.video_mode
TODO Improve this example with something useful.
NOTE This method must be called inside a CrystGLFW#run
block definition.
Returns the monitor's supported video modes.
TODO Add an example here.
NOTE This method must be called from within a CrystGLFW#run
block definition.