1
\$\begingroup\$

I am trying to write a fullscreen toggle handler and running into an issue.

In order to change between fullscreen and windowed I need to destroy the current window and create a new one with the 'monitor' parameter changed. I have written this and the program changes between windowed and fullscreen fine. However the new window that is created is not being rendered to and is black.

For simplicity I have reduced the code to the following that just creates a new window with the same parameters:

/* generic set up stuff */

//main draw loop
while (!glfwWindowShouldClose(window)) {

    /* generic draw stuff */

    if (GLFW_PRESS == glfwGetKey(window, GLFW_KEY_F)){
        glfwDestroyWindow(window);
        window = glfwCreateWindow(g_gl_width, g_gl_height, "Title", NULL, NULL);
        glfwMakeContextCurrent(window);
    }
}

When the program first loads everything renders fine. When I hit F, a new window is created but it stays black.

Any ideas?

Kind regards.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Did you reload all the resources? A new context means new textures, framebuffers, shaders, etc. must be created. \$\endgroup\$
    – user41442
    Jul 17, 2014 at 18:55

1 Answer 1

1
\$\begingroup\$

You need to set up the viewport again, by calling glViewport.

Also, I believe a context is bound to the window and not to the thread, but I could be wrong. If this is the case, then you'll have to set up all your resources, buffers, etc..

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .