[rcore_desktop] Can't get size of the monitor before creating a window
albertvaka opened this issue · comments
Code Example
printf("monitor: %d width: %d\n", GetCurrentMonitor(), GetMonitorWidth(GetCurrentMonitor()));
InitWindow(200, 200, "Hola");
printf("monitor: %d width: %d\n", GetCurrentMonitor(), GetMonitorWidth(GetCurrentMonitor()));
Prints:
WARNING: GLFW: Failed to find selected monitor
monitor: 0 width: 0
monitor: 0 width: 3840
Issue description
I would like to know the resolution of the (default) monitor so I can create a bigger window if it fits (and scale up my game). Currently it is only possible to query the monitor resolution after a window has already been created, which is too late.
If there are multiple monitors, I expect this to give me the resolution of the default monitor (where the window will be created).
Environment
Windows 11, RTX4070
I'm afraid it's not possible to query the display/monitor info until it is created. It will require a redesign of raylib with some kind of Init() function, compketely out of scope.
In any case, you can create an invisible window, query required data, close it and InitWindow() again.
@raysan5
The utility nfoPixel.h
and platform-specific implementation (e.g., nfoPixel-Win32.c
) I am pondering operates completely outside of raylib and will alleviate this problem. It will run with or without raylib operating. It is intended to provide rapid scaling functions although it will be usable for the purpose @albertvaka describes. See Discussion #3342.