Search code examples
c++openglunhandled-exception

Opengl in C++: Unhandled exception when compiler reads glBindVertexArray


I have been advised against using immediate calls in opengl so I am trying to move over to vertex arrays. Whenever I run my program I get this error when it tries to read glBindVertexArray: "Unhandled exception at 0x7540CB49 in TestOpenGL.exe: 0xC0000005: Access violation executing location 0x00000000."

Why is it giving me this error?


Solution

  • glewInit must be called after the OpenGL context has been created. If you call it before that, it won't do anything. It depends on the way you create your OpenGL window, when that happend. If using GLUT, GLFW or SDL the OpenGL context is available after the window has been created. If you program directly against the OS APIs, then after the OpenGL context "make current" function has been called.