# How to set to fullscreen in GLFW3?

In the version 2.7 everything was pretty simple:

glfwOpenWindow(Width, Height, 8, 8, 8, 8, 24, 0, isFullscr ? GLFW_FULLSCREEN : GLFW_WINDOW);


But in version 3.x there is no place where i can specify how my my window should be and by default its windowed:

glfwCreateWindow(width, height, m_windowName.c_str(), nullptr, nullptr);


How can i change my window to fullscreen mode?

• Wow. I was thinking "surely this must be clearly defined in the documentation" ... but it isn't. Serious oversight on their part. I think maybe you just have to set the monitor parameter in glfwCreateWindow ? Jul 3, 2013 at 19:33

In 3.x, you specify which monitor you want to use for fullscreen instead of the flag in 2.x.

You can use glfwGetPrimaryMonitor() to get a monitor handle and pass it into glfwCreateWindow() as follows:

glfwCreateWindow(width, height, m_windowName.c_str(), glfwGetPrimaryMonitor(), nullptr);


As long as monitor param is not null, it will create full screen window on the monitor specified. This was done to support multiple monitors.

As for various attributes for the window, you need to use window hints by calling glfwWindowHint with appropriate parameters and then make theglfwCreateWindow call.

Read the docs, its very clear.

 int main()
{
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_SAMPLES,32); // Uhuh?

glfwWindowHint(GLFW_DECORATED, NULL); // Remove the border and titlebar..

GLFWmonitor* MyMonitor =  glfwGetPrimaryMonitor(); // The primary monitor.. Later Occulus?..

const GLFWvidmode* mode = glfwGetVideoMode(MyMonitor);
SCR_WIDTH = mode->width;
SCR_HEIGHT = mode->height;

// GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL); // Original..

// GLFWwindow* window =  glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "My Title", NULL, NULL); // Title now redundant..

// More elegant?? (the flash still bothers me..)
GLFWwindow* window =   glfwCreateWindow(glfwGetVideoMode(glfwGetPrimaryMonitor())->width,
glfwGetVideoMode(glfwGetPrimaryMonitor())->height, "My Title",
glfwGetPrimaryMonitor(), nullptr);

• This answer would be better if it included some text explaining how & why this solves the problem. Jul 8, 2020 at 1:43

To have your window be full screen and eat it too -- I mean, not have the white flashing as described in other answers, do the following:

• create the window at a sufficiently low resolution (to avoid the white flash)
• then resize it to your screen's resolution.
GLFWmonitor* monitor = glfwGetPrimaryMonitor();

GLFWwindow* window = glfwCreateWindow(low_res_x, low_res_y, "title", monitor, NULL);

glfwSetWindowSize(window, 1920, 1080);