I'm not sure about common practices, but lacking a glfwToggleFullscreen, this seems one way to toggle fullscreen mode:
// On input handling, check if F11 is down.
if ( glfwGetKey( GLFW_KEY_F11 ) ) {
// Toggle fullscreen flag.
fullscreen = !fullscreen;
// Close the current window.
glfwCloseWindow();
// Renew calls to glfwOpenWindowHint.
// (Hints get reset after the call to glfwOpenWindow.)
myGLFWOpenWindowHints();
// Create the new window.
glfwOpenWindow(Width, Height, 8, 8, 8, 8, 24, 0,
fullscreen ? GLFW_FULLSCREEN : GLFW_WINDOW);
}
Another method, this time for fullscreen windowed mode:
// Create your window in windowed mode.
glfwOpenWindow(originalWidth, originalHeight, 8, 8, 8, 8, 24, 0, GLFW_WINDOW);
glfwSetWindowPos(originalPosX, originalPosY);
// Get the desktop resolution.
GLFWvidmode desktopMode;
glfwGetDesktopMode(&desktopMode);
desktopHeight = desktopMode.Height;
desktopWidth = desktopMode.Width;
// --8<--
// On input handling, check if F11 is down.
if ( glfwGetKey( GLFW_KEY_F11 ) ) {
// Toggle fullscreen flag.
fullscreen = !fullscreen;
if ( fullscreen ) {
// Set window size for "fullscreen windowed" mode to the desktop resolution.
glfwSetWindowSize(desktopWidth, desktopHeight);
// Move window to the upper left corner.
glfwSetWindowPos(0, 0);
} else {
// Use start-up values for "windowed" mode.
glfwSetWindowSize(originalWidth, originalHeight);
glfwSetWindowPos(originalPosX, originalPosY);
}
}