Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Segmentation fault on glGenVertexArrays

📅 2014-Jul-08 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ error, glew, opengl ⬩ 📚 Archive

Problem

I was trying to compile the code from the book Interactive Computer Graphics: A Top-Down Approach with Shader-Based OpenGL (6th Edition). The code compiled fine, but execution failed with SIGSEGV segmentation fault at the line:

GLuint vao;
glGenVertexArrays( 1, &vao );

Solution

The system might be using an old version of GLEW, where glGenVertexArrays is still marked as an experimental OpenGL extension. To enable the use of such experimental extensions add these lines during initialization:

glewExperimental = GL_TRUE; 
glewInit();

Tried with: NVIDIA GeForce 9600 GT, NVIDIA drivers 331 and Ubuntu 14.04