title: Vertex Buffer Objects Open GL
body: <p>I am really new to Open GL and I am trying to build non deprecated code. Now what I can't grasp is VBO. This is all I got so far, can you please explain what I'm supposed to be doing. Also, I have the OpenGL programming guide, so if you can point out some pages to read that would be very helpful as well.</p>
  
  <pre><code>#include &lt;GL/glew.h&gt;
  #include &lt;GL/freeglut.h&gt; 
  
  GLuint ID[2];
  GLfloat PositionData[][2] ={{50,50},{100,50},{50,100}, {100,50}, {100, 100}, {50, 100}};
  GLfloat Colors[][3] = {{0.1, 0.2, 0.3},{0.1, 0.2, 0.3},{0.1, 0.2, 0.3},{0.1, 0.2, 0.3},{0.1, 0.2, 0.3}};
  
  void init(){
      glewInit();
      glClearColor(1.0, 1.0, 1.0, 0.0);
  }
  
  void display(){
      glClear(GL_COLOR_BUFFER_BIT);
      glShadeModel(GL_FLAT);
      glGenBuffers(2, ID);
      glBindBuffer(GL_ARRAY_BUFFER, ID[0]);
      glBufferData(GL_ARRAY_BUFFER, sizeof(PositionData), PositionData, GL_STATIC_DRAW);
      glEnableClientState(GL_VERTEX_ARRAY);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
      glEnableVertexAttribArray(0);
      glBindBuffer(GL_ARRAY_BUFFER, ID[1]);
      glBufferData(GL_ARRAY_BUFFER, sizeof(Colors), Colors, GL_STATIC_DRAW);
      glEnableClientState(GL_COLOR_ARRAY);
      glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
      glEnableVertexAttribArray(1);
  
      glDrawArrays(GL_TRIANGLES, 0, 12);
  
      glDisableVertexAttribArray(0);
      glDisableVertexAttribArray(1);
      glDeleteBuffers(2, ID);
      glFlush();
  }
  
  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);
  }
  
  int main(int argc, char *argv[]){
      glutInit(&amp;argc, argv);
      glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
      glutInitWindowSize(500, 500);
      glutInitWindowPosition(100, 100);
      glutCreateWindow("I don't get VBOs");
      init();
      glutDisplayFunc(display);
      glutReshapeFunc(reshape);
      glutMainLoop();
      return 0;
  }
  </code></pre>