title: glGenBuffers() crashing with Segmentation fault. (C++/GLFW/GLEW)
body: <p>So, in my project I am using a seperate class to create buffers called Buffer.cpp. Here is the constructor</p>
  
  <pre><code>#define GLEW_STATIC
  #define GLEW_NO_GLU
  #define GLFW_NO_GLU
  
  #include "GL/glew.h"
  #include "GL/glfw.h"
  
  Buffer::Buffer(GLenum _type, const void *data, GLsizei _size, GLenum usage) :  type(_type), size(_size)
  {
    ...
  
    //Generate Buffer
    glGenBuffers(1, &amp;buffer);
  
    ...
  }
  </code></pre>
  
  <p>And the definitions of the members:</p>
  
  <pre><code>GLuint buffer;
  const GLsizei size; 
  const GLenum type;
  Buffer(GLenum, const void*, GLsizei, GLenum);
  </code></pre>
  
  <p>The problem is that when I try to generate a buffer using for example this command:</p>
  
  <pre><code>Buffer vBuffer(GL_ARRAY_BUFFER, vertexPositions, sizeof(vertexPositions), GL_STATIC_DRAW);
  </code></pre>
  
  <p>the program crashes at glGenBuffers() with termination status "-1073741819". I tried debugging the program and this is what I got:</p>
  
  <pre><code>Program received signal SIGSEGV, Segmentation fault.
  </code></pre>
  
  <p>My card supports OpenGL 1.5 so that's not the case.</p>
  
  <p>It is also worth to note that I compiled a static glew library myself.</p>
  
  <p><strong>EDIT:</strong> I finally fixed the problem. The problem was that I was calling glewInit() before creating an OpenGL rendering context.</p>