Why do I fail to create a window with GLFW on Windows?

10,322

Looks like there is an issues with your OpenGL drivers on Windows.

Try to check and update your OpenGL drivers :

  • Install an OpenGL viewer, such as the GLview utility, to view the OpenGL version installed on your machine.
  • For Windows XP, Windows Vista, and Windows 7, open the viewer to find the version and driver version under OpenGL running on your computer.
  • Click the “Check for updated drivers” link to identify if any driver updates are necessary.

Excerpts taken from this website.

Share:
10,322
LiziPizi
Author by

LiziPizi

Updated on June 05, 2022

Comments

  • LiziPizi
    LiziPizi almost 2 years

    I'll be glad if someone could please tell me what is the issue here:

    int main() {
    
        glfwWindowHint(GLFW_SAMPLES, 4);
        glfwWindowHint(GLFW_VERSION_MAJOR, 3);
        glfwWindowHint(GLFW_VERSION_MINOR, 3);
        glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    
        GLFWwindow* window;
        window = glfwCreateWindow(1024, 768, "window", NULL, NULL);
    
    }
    
    • slaadvak
      slaadvak almost 10 years
      On which OS are you running this application ?
    • Keyur Padalia
      Keyur Padalia almost 10 years
      What do you do once you have the window? Do you enter an event loop of sorts? Maybe the window is created just fine, but disappears immediately.
    • LiziPizi
      LiziPizi almost 10 years
      @thomas no, it just says "Failed to create a GLFW window", like I just told it to when it fails
    • Keyur Padalia
      Keyur Padalia almost 10 years
      By the way, don't do glfwInit() == false, as it returns an int. Just do !glfwInit().
    • LiziPizi
      LiziPizi almost 10 years
      @Thomas it still fails
    • Keyur Padalia
      Keyur Padalia almost 10 years
      From the docs: "Windows: Window creation will fail if the Microsoft GDI software OpenGL implementation is the only one available." So this might be a driver issue.
    • LiziPizi
      LiziPizi almost 10 years
      @Thomas I thought about it too but my driver is updated, it may be the gpu..
    • Jherico
      Jherico almost 10 years
      Have you tried turning off some of the hints to see if you can get a window if you don't specify Core Profile 3.3 and samples?
    • LiziPizi
      LiziPizi almost 10 years
      @jherico wow ty, I deleted those 4 lines and it work, but the question if I need them? what they even do?
    • LiziPizi
      LiziPizi almost 10 years
      @Jherico wow ty, I deleted those 4 lines and it work, but the question if I need them? what they even do?
    • Jherico
      Jherico almost 10 years
      You should try adding them back individually and see which one was causing the problem (although the major/minor version items should be added as a pair. It's likely that your driver simply doesn't support a specific OpenGL version, or the core profile specifically (although I think 3.3 requires core profile support, so it's probably a matter of both). Or it's possible that your card doesn't support multisampling and GLFW isn't finding a suitable fallback pixel format (although it should since it's only a hint, so that might be a bug in GLFW).
    • LiziPizi
      LiziPizi almost 10 years
      @Jherico hey I found out that it was this line: glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);