Does anyone know how to toggle fullscreen to windowed in GLFW? I understand that the context is lost during the transition as you have to use glfwCreateWindow, however I have passed the original context as a parameter to that method which I was under the impression shared the context resources?
I then destroy the old window and mark the new context as current
// With GLFW we have to create a new window and destroy the old after making sure we enable the new context
GLFWwindow* tempWindowPtr = glfwCreateWindow(
this->renderWindow_Width,
this->renderWindow_Height,
this->renderWindow_Title.c_str(),
this->renderWindow_Fullscreen ? this->renderWindow_DisplayMonitor : NULL,
this->renderWindow_hWnd);
if(!tempWindowPtr)
{
GLogManager::GetSingleton().WriteLine("Error setting new display settings.", GLogManager::Error);
this->shouldApplyNewSettings = false;
return GR_FAILURE;
}
glfwDestroyWindow(this->renderWindow_hWnd); // destroy the old window
this->renderWindow_hWnd = tempWindowPtr; // swap the pointers
glfwMakeContextCurrent(this->renderWindow_hWnd);
I then proceed to recreate my callbacks as I understand the glfw state as well as the OpenGL state is lost, but as I understood it the resources, ie textures, shaders etc won't need to be recreated?? However it seems that I just get a black screen when running the above. Running the output through gDebugger i get:
Debug String: Detected error: The debugged process asked for an extension function pointer (glActiveTexture) from one render context, but called this function pointer in another render context (context #2)