20 "GLFWSingleton::configure() called after GLFW was initialized — pre-init hints will be ignored");
25 int glfw_platform = GLFW_ANY_PLATFORM;
28 glfw_platform = GLFW_PLATFORM_WAYLAND;
31 glfw_platform = GLFW_PLATFORM_X11;
36 glfwInitHint(GLFW_PLATFORM, glfw_platform);
39 glfwInitHint(GLFW_WAYLAND_LIBDECOR, config.
disable_libdecor ? GLFW_FALSE : GLFW_TRUE);
41 glfwInitHint(GLFW_COCOA_MENUBAR, config.
cocoa_menubar ? GLFW_TRUE : GLFW_FALSE);
46 "GLFW pre-initialization configured: platform={}, libdecor={}, cocoa_chdir_resources={}, cocoa_menubar={}",
66 "GLFWSingleton::initialize() called without prior configure() — using default pre-init hints");
71 glfwSetErrorCallback([](
int error,
const char* description) {
99 GLFWmonitor** monitors = glfwGetMonitors(&count);
101 std::span<GLFWmonitor*> monitor_span(monitors, count);
103 std::vector<MonitorInfo> infos;
104 infos.reserve(count);
106 GLFWmonitor* primary = glfwGetPrimaryMonitor();
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);
113 infos.push_back({ .id = i,
114 .name = glfwGetMonitorName(monitor_span[i]),
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) });
133 for (
const auto& m : monitors) {
145#if GLFW_VERSION_MAJOR >= 3 && GLFW_VERSION_MINOR >= 4
146 int platform = glfwGetPlatform();
148 case GLFW_PLATFORM_WAYLAND:
150 case GLFW_PLATFORM_X11:
152 case GLFW_PLATFORM_WIN32:
154 case GLFW_PLATFORM_COCOA:
160 const char* platform = glfwGetPlatformName();
164#ifdef MAYAFLUX_PLATFORM_LINUX
165#ifdef GLFW_USE_WAYLAND
170#elif MAYAFLUX_PLATFORM_WINDOWS
172#elif MAYAFLUX_PLATFORM_MACOS
188 if (
id >= 0 &&
static_cast<size_t>(
id) < monitors.size()) {
203 std::source_location::current(),
204 "GLFW must be initialized before querying required instance extensions");
208 const char** extensions = glfwGetRequiredInstanceExtensions(&count);
209 if (!extensions || count == 0) {
211 "No required instance extensions reported by GLFW");
215 return { extensions, extensions + count };
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
static std::string get_platform()
Gets the current GLFW platform (Wayland, X11, etc.)
static uint32_t s_window_count
Number of currently active GLFW windows.
static void set_error_callback(std::function< void(int, const char *)> callback)
Sets a custom error callback for GLFW errors.
static bool initialize()
Initializes the GLFW library if not already initialized.
static void terminate()
Terminates the GLFW library if initialized and no windows remain.
static std::vector< const char * > get_required_instance_extensions()
Retrieves the list of required Vulkan instance extensions for GLFW.
static GlfwPreInitConfig s_preinit_config
static std::function< void(int, const char *)> s_error_callback
Internal GLFW error callback that forwards to the user-defined callback if set.
static MonitorInfo get_monitor(int32_t id)
Retrieves information about a specific monitor by ID.
static void configure(const GlfwPreInitConfig &config)
Configures GLFW with pre-initialization hints.
static MonitorInfo get_primary_monitor()
Retrieves information about the primary monitor.
static std::vector< MonitorInfo > enumerate_monitors()
Enumerates all connected monitors and their information.
static bool is_wayland()
Checks if running on Wayland.
static bool s_initialized
Tracks whether GLFW has been initialized.
@ WindowingSubsystem
Windowing system operations (GLFW, SDL)
@ Core
Core engine, backend, subsystems.
enum MayaFlux::Core::GlfwPreInitConfig::Platform platform
bool cocoa_chdir_resources
bool disable_libdecor
this prevents crash on some wayland compositors
Configuration hints for GLFW initialization.
Information about a physical display.