title: glBindBuffer crash - VBO implementation with glew
body: <p>I've been trying to implement VBO on my computer and I ran into a segmentation fault:</p>
  
  <pre><code>Unhandled exception at 0x00000000 in attocube.exe: 0xC0000005: Access violation
  </code></pre>
  
  <p>The error is at the line where I call <code>glBindBuffer(GL_ARRAY_BUFFER, ID);</code> in <code>void init()</code>.
  I've used the code of the following question: <a href="https://stackoverflow.com/questions/3121472/how-to-get-vbo-working">How to get VBO working</a></p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;iostream&gt;
  #include &lt;GL/glew.h&gt;
  #include &lt;GL/freeglut.h&gt;
  
  #pragma comment(lib,"glew32.lib")
  
  GLuint ID;
  
  void init(){
      glewInit();
      glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
      glShadeModel(GL_FLAT);
      glEnableClientState(GL_VERTEX_ARRAY);
      float data[][2] = {{50,50},{100,50},{75,100}};
      glGenBuffers(1,&amp;ID);
      glBindBuffer(GL_ARRAY_BUFFER, ID);
      glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
  }
  
  void reshape(int w, int h){
      glViewport(0,0, (GLsizei) w, (GLsizei) h);
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      gluOrtho2D(0.0f, (GLdouble) w, 0.0f, (GLdouble) h);
  }
  
  void display(){
      glClear(GL_COLOR_BUFFER_BIT);
      glColor3f(0.0f,0.0f,0.0f);
      glBindBuffer(GL_ARRAY_BUFFER, ID);
      glVertexPointer(2, GL_FLOAT, 2*sizeof(float), 0);
      glDrawArrays(GL_TRIANGLES,0,3);
      glFlush();  
  }
  
  int main(int argc, char **argv){
      glutInit(&amp;argc,argv);
      glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
      glutInitWindowSize(500,500);
      glutInitWindowPosition(300,300);
      glutCreateWindow(argv[0]);
      init();
      glutDisplayFunc(display);
      glutReshapeFunc(reshape);
      glutMainLoop();
      return 0;
  }
  </code></pre>
  
  <p>My configuration is the following:
  Windows 7 / Geforce GTX 570 / glew 1.9.0</p>