Crashing when exiting GLFW 3.0.3 on fullscreen mode

rebirth123 wrote on Monday, October 14, 2013:

GLFW 2 worked flawlessly but I decided to try out this new version and experience the changes. I can get it to work in a windowed mode without any problems, but as soon as I try fullscreen mode I am getting serious lock ups which is forcing me to hard reset my PC.

I have tried to setup fullscreen with a lower resolution than the native resolution on my primary monitor, but this results in a total black screen lockup. If I set the resolution to the native (current) resolution of my primary monitor then opengl renders correctly, but as soon as I press escape to exit, I get a total black screen lockup which forces me to hard reset my PC. Alt-Ctrl-Del is not working, so this makes it difficult (and tedious) to find a fix.

Windows 7 sp1
GTX 780
Multi-monitor configuration

Here is the initialization code:

bool initialize(int wWidth, int wHeight, bool fullScreen, std::string title)

	return false;

glfwWindowHint(GLFW_STENCIL_BITS, 8);
glfwWindowHint(GLFW_DEPTH_BITS, 24);
glfwWindowHint(GLFW_SAMPLES, 0);

        _window = glfwCreateWindow(wWidth, wHeight, title.c_str(), glfwGetPrimaryMonitor(), NULL);
        _window = glfwCreateWindow(wWidth, wHeight, title.c_str(), NULL, NULL);

    return false;

    glfwSetWindowSizeCallback(_window, _windowResizeCallback);
glfwGetFramebufferSize(_window, &_windowWidth, &_windowHeight);
glfwSetKeyCallback(_window, _keyCallback);

glewExperimental = true;
GLenum err = glewInit();
if(GLEW_OK != err) 
	return false;

    printf("GL Version: %s\n", glGetString(GL_VERSION));
    return true;


void shutdown()
//glfwDestroyWindow(_window); //tried to comment this out but made no difference

Hope you can help.

P.S. I took out all of the GL error checks in my paste (to save space for the relevant code) GL is reporting no errors.

elmindreda wrote on Monday, October 14, 2013:

Are you calling shutdown from a callback?

rebirth123 wrote on Monday, October 14, 2013:

No, I’m not. At the moment the _keyCallback function is just like the example:

void _keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GL_TRUE);

The rendering while loop is controlled with the glfwWindowShouldClose(_window) function.

The shutdown() function is called just before the program ends in int main() and is the last function called, after I have destroyed all objects/shaders etc.

It works fine in windowed mode and a similar setup using GLFW2 in fullscreen mode. All monitors go black when it locks up, which I imagine is a graphics driver crash (latest official Nvidia drivers).

rebirth123 wrote on Tuesday, October 15, 2013:

I believe I have a problem with my PC. I have written a very basic program using glfw3 to run on my old Aspire 5738g laptop and it’s working OK.

I don’t believe the problem is related to the Nvidia driver (I tried others), but it may either be a problem in the OS or a fault with the GFX card (it’s fairly new). However, the latter seems unlikely as it functions fine in all games and tests.

rebirth123 wrote on Tuesday, October 15, 2013:

Actually, this gets even stranger, and happens in both VS2010 and VS2012.

If I close down the IDE and run the built executables, the program behaves perfectly with no black screen crashes on exit.

I am now convinced GLFW3 works flawlessly as GLFW2 does (I tested other win32 methods too), but am at a total loss as to what is going on.

Does anyone know why this might be happening when running the program from these IDEs in fullscreen mode (F5 - debug mode)? I don’t ever recall this happening before.

rebirth123 wrote on Wednesday, October 16, 2013:

After a reinstall of OS and software everything is working fine again. Sadly, the problem coincided with the time I started to test out GLFW, so I created this thread to see if there was something obviously wrong with the initialization code.

The problems in this thread are not related to GLFW3, which is actually very good with some well-thought out features.

Sorry for wasting your time.