I try to make the program have a fullscreen toggle functionality by pressing a key. If I’m not mistaken, the only way to make a window full screen is to create it using the line
So in the keyboard callback function I added the following code
glfwSetWindowShouldClose(oldwindow, GL_TRUE);
//glfwDestroyWindow(oldwindow); // I read somewhere that this line destroy the context as well
GLFWwindow* newwindow = glfwCreateWindow(width, height, "title", glfwGetPrimaryMonitor(), 0);
glfwMakeContextCurrent(newwindow);
But after pressing the key the newly created window pop up and is completely black screen. Do I have to send all the objects’ drawing states from the oldwindow to the newwindow?
Switching to fullscreen and back is a painful process (no matter what library you use).
If you simply destroy your window and create a new one, not only you lose all your states, but you also have to reload all your textures, because you also destroyed OpenGL context. This is how OpenGL itself is organised.
For textures and shaders to survive window recreation you should use context sharing. That way you’ll only need to set OpenGL states again, attach callbacks to newly created window and recreate some other OpenGL things vulnerable to window switching (textures don’t need to be reloaded).