# glGenVertexArray crash my program

Hi I started today to make an OpenGL program, I made the shader class, mesh class and texture class. When I tried to test it, it stopped working. After a little debug with Visual Studio(thanks Microsoft for this useful tool). It showed me that my problem is:

glGenVertexArrays(1, &m_vao);


I use glew. I searched on internet, and I found that glewExperimental needs to be GL_TRUE, so I init it like this:

glewExperimental = GL_TRUE;
GLenum error = glewInit();
if (error != GLEW_OK)
std::cerr << "Glew: " << glewGetErrorString(error);


nothing changed.

Error given by Visual Studio:

Exception thrown at 0x00000000 in DirtyCraft.exe: 0xC0000005: Access violation executing location 0x00000000. occurred


I do use Glew 2.0.0, 32-bits, SDL2.

If you need any additional information, feel free to request them.

• (1) what graphics hardware have you? (2) did you call glewInit before or after creating your GL context? – Maximus Minimus Jul 31 '17 at 18:16
• I have a gtx 950, and glewInit is called after context creation, it's the last part of the window constructor – Laceanu George Jul 31 '17 at 18:42
• Thanks. Are you able to create shaders and buffers or do you crash on those too? Rearrange some code if necessary. Right now it seems as though you're not getting a hardware-accelerated GL context. – Maximus Minimus Jul 31 '17 at 20:13
• I'm not at my pc, but it could be a problem of linking? – Laceanu George Jul 31 '17 at 22:01
• Btw, shaders works, not tested them, but I saw compile errors. – Laceanu George Jul 31 '17 at 22:01

## 1 Answer

The Window that holds the rendering must be opened first. Also, you need to call glew first before calling any opengl functions.

• thank you, but I solved. Somehow glDrawElements was messing up something in glew, so I reinstalled glew – Laceanu George Aug 9 '17 at 19:46