Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GLFW Toggling Windowed-Fullscreen Mode

I am using GLFW and I would like to know how to toggle full-screen windowed mode. Not changing the resolution, but instead setting the window to be on top and without decoration. If GLFW is not capable of doing this, then what cross platform library do you suggest to achieve this?

like image 244
erai Avatar asked Apr 20 '12 20:04

erai


3 Answers

You can tell glfw to open your window fullscreen.

glfwOpenWindow( width, height, 0, 0, 0, 0, 0, 0, GLFW_FULLSCREEN )

As far as I know you would have to close and reopen this window to switch between a window and fullscreen mode.

like image 175
user789805 Avatar answered Nov 02 '22 14:11

user789805


To avoid GLFW changing the screen resolution, you can use glfwGetDesktopMode to query the current desktop resolution and colour depth and then pass those into glfwOpenWindow.

// get the current Desktop screen resolution and colour depth
GLFWvidmode desktop;
glfwGetDesktopMode( &desktop );

// open the window at the current Desktop resolution and colour depth
if ( !glfwOpenWindow(
    desktop.Width,
    desktop.Height,
    desktop.RedBits,
    desktop.GreenBits,
    desktop.BlueBits,
    8,          // alpha bits
    32,         // depth bits
    0,          // stencil bits
    GLFW_FULLSCREEN
) ) {
    // failed to open window: handle it here
}
like image 21
james Avatar answered Nov 02 '22 15:11

james


Since version 3.2:

Windowed mode windows can be made full screen by setting a monitor with glfwSetWindowMonitor, and full screen ones can be made windowed by unsetting it with the same function.

http://www.glfw.org/docs/latest/window.html

like image 2
bwroga Avatar answered Nov 02 '22 16:11

bwroga