MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ enumerate_monitors()

std::vector< MonitorInfo > MayaFlux::Core::GLFWSingleton::enumerate_monitors ( )
static

Enumerates all connected monitors and their information.

Returns
A vector of MonitorInfo structs for each connected monitor

Queries GLFW for the list of connected monitors and retrieves their properties such as name, dimensions, and current video mode.

Definition at line 93 of file GlfwSingleton.cpp.

94{
95 if (!s_initialized)
96 return {};
97
98 int count {};
99 GLFWmonitor** monitors = glfwGetMonitors(&count);
100
101 std::span<GLFWmonitor*> monitor_span(monitors, count);
102
103 std::vector<MonitorInfo> infos;
104 infos.reserve(count);
105
106 GLFWmonitor* primary = glfwGetPrimaryMonitor();
107
108 for (int i = 0; i < count; ++i) {
109 auto* mode = glfwGetVideoMode(monitor_span[i]);
110 int w_mm {}, h_mm {};
111 glfwGetMonitorPhysicalSize(monitor_span[i], &w_mm, &h_mm);
112
113 infos.push_back({ .id = i,
114 .name = glfwGetMonitorName(monitor_span[i]),
115 .width_mm = w_mm,
116 .height_mm = h_mm,
117 .current_mode = {
118 .width = static_cast<uint32_t>(mode->width),
119 .height = static_cast<uint32_t>(mode->height),
120 .refresh_rate = static_cast<uint32_t>(mode->refreshRate),
121 .red_bits = static_cast<uint8_t>(mode->redBits),
122 .green_bits = static_cast<uint8_t>(mode->greenBits),
123 .blue_bits = static_cast<uint8_t>(mode->blueBits) },
124 .is_primary = (monitor_span[i] == primary) });
125 }
126
127 return infos;
128}
static bool s_initialized
Tracks whether GLFW has been initialized.

References s_initialized.

Referenced by get_monitor(), and get_primary_monitor().

+ Here is the caller graph for this function: