OpenGL window flashes then closes

I have create an OpenGl window with GLFW but when i run it the window opens and then isntantly closes is this something to do with my hardware not supporting a certain opengl version?

No, it’s a bug in your own code. That’s the first thing you should always assume when you get incorrect behaviour: that your own code is at fault.

Its source code is from a website of a book so I would have presumed it was bug free if others could run it

Quite possibly. The code in question (6th edition SuperBible) requires at least OpenGL 4.1, possibly later. The website states that some of the examples won’t work on OSX 10.9 due to it “only” supporting 4.1. The commit messages for the GitHub repository indicate that some of the shaders had their version downgraded to 410 for this reason, but it’s unclear whether all of the examples now work with 4.1, or whether any of them will work with an older version.

You can probably find out exactly why the application fails by either running it from a command prompt (if the program has to create its own console window, it will close when the program terminates), or running it under a debugger and single-stepping through the initialisation.

Thank you GClements im guessing that is it I checked my opengl supported versionswith openglev and 3.1 is my supported verisons so i guess ill get a book on that version. Thank you :slight_smile: