Actively choosing between fullscreen and windowed fullscreen

Hello !

I’ve been looking at the window guide recently and I’ve tried to implement reliable functions to switch between the three modes (windwed, windowed fullscreen and fullscreen).
My main question is how i could more actively choose between windowed fullscreen and fullscreen without having to do something that would feel like a hack like actively choosing a different video mode to choose fullscreen or the opposite for windowed fullscreen. Especially since i would need to recreate the window with different hints for stuff like color bit depth.
I’m also fine with sticking to a single fullscreen mode but how should i go about choosing the one i want? Do i really need to choose a different video mode from the one used by a monitor just to have a “true” fullscreen window?

Thanks in advance !

Hi & welcome to the GLFW forum!

The windowed fullscreen mentioned in the GLFW Window creation documentation refers to the fact that GLFW itself does not set a video mode if the video mode selected is the current window monitors video mode.

As this comment on Choosing between normal fullscreen and windowed fullscreen mode #1036 mentions:

There is no difference between these things for OpenGL at the platform API level. The difference described in the documentation only refers to whether a video mode is set, but I phrased it in Direct3D terms as those are so pervasive in gamedev.

Technically there are ways to explicitly choose between copying and page flipping on Windows. However, modern drivers appear to ignore these requests and instead decide whether a window gets page flipping based on its size, position and z-order.

So there the windowed fullscreen mode is really:

  1. Get the monitor the window is on. This can currently be done by finding the monitor which the window is in, though there may be an API for this in future.
  2. Get the monitors video mode with glfwGetVideoMode( monitor )
  3. Set the window’s monitor with glfwSetWindowMonitor using the monitor and video mode from above.

The most robust way to get the monitor the window is on is to check the overlap of the window and the monitor with glfwGetWindowPos and glfwGetWindowSize for the window and glfwGetMonitorWorkarea for the monitor. If there is no overlap get the closest.

1 Like

Thanks for the quick answer !

I would like to use the vulkan api if this changes anything with how the modes work.

I still have a few questions concerning this topic, namely :
Is there no extra latency involved in using a windowed fullscreen window? (multiple sources online state otherwise)
Do i need matching color bit depth or is a matching resolution and framerate enough to get a windowed fullscreen window?
Does a fullscreen window only get created if the resolution or the framerate of the window doesn’t match the screen’s vidmode?

This is a somewhat complex issue.

This does not change anything about how the video mode setting works in GLFW, but Vulkan has some control for Windows prior to 11 with VK_EXT_full_screen_exclusive. There is a decent Full Screen Exclusive sample, see the code highlighted in this link.

Is there no extra latency involved in using a windowed full-screen window? (multiple sources online state otherwise)

It depends in ways which are mostly out of your control.

Do i need matching color bit depth or is a matching resolution and framerate enough to get a windowed full-screen window?

Framerate, yes. However colour bit depth of the frame buffer can be different from the colour bit depth of the monitor video mode.

Does a fullscreen window only get created if the resolution or the framerate of the window doesn’t match the screen’s vidmode?

Somewhat yes. Changing resolution of the monitor will involve a mode change and minimizing it will involve a mode change back. When people refer to windowed full-screen they often mean one which does not involve a mode change, and can have overlays. The first you have some control over, the second depends on OS and drivers.