Crashing when exiting GLFW 3.0.3 on fullscreen mode

Using GLFW
Chris
2013-10-14
2013-10-16
  • Chris
    Chris
    2013-10-14

    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
    VS2010

    Here is the initialization code:

    bool initialize(int wWidth, int wHeight, bool fullScreen, std::string title)
    {
    glfwSetErrorCallback(_errorCallback);

    if(!glfwInit())
    {
        return false;
    }
    
    glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
    glfwWindowHint(GLFW_STENCIL_BITS, 8);
    glfwWindowHint(GLFW_DEPTH_BITS, 24);
    glfwWindowHint(GLFW_SAMPLES, 0);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    
        if(fullScreen)
            _window = glfwCreateWindow(wWidth, wHeight, title.c_str(), glfwGetPrimaryMonitor(), NULL);
        else
            _window = glfwCreateWindow(wWidth, wHeight, title.c_str(), NULL, NULL);
    
        if(!_window)
        {
            glfwTerminate();
        return false;
        }
    
        glfwSetWindowSizeCallback(_window, _windowResizeCallback);
    glfwGetFramebufferSize(_window, &_windowWidth, &_windowHeight);
    glfwSetKeyCallback(_window, _keyCallback);
    glfwMakeContextCurrent(_window);
    
    glewExperimental = true;
    GLenum err = glewInit();
    if(GLEW_OK != err) 
    {
        shutdown();
        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
    glfwTerminate();
    }

    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.

     
    Last edit: Chris 2013-10-14
  • Camilla Löwy
    Camilla Löwy
    2013-10-14

    Are you calling shutdown from a callback?

     
    • Chris
      Chris
      2013-10-14

      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).

       
      Last edit: Chris 2013-10-14
  • Chris
    Chris
    2013-10-15

    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.

     
    Last edit: Chris 2013-10-15
  • Chris
    Chris
    2013-10-15

    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.

     
    Last edit: Chris 2013-10-15
  • Chris
    Chris
    2013-10-16

    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.

     
    Last edit: Chris 2013-10-16