title: C++/OpenGL - Drawing a cube VBO
body: <p>Recently I started to learn OpenGL and I am beginning to learn the newer assets of it. For a while now I've been trying to work with VBOs, to draw a simple cube from a vertex point array. I am having trouble rendering it and understanding some of the arguments in the functions. It throws no errors but nothing is in my view.</p>
  
  <pre><code>float cubeVertPoints[72]; //An array containing the vertex points
  </code></pre>
  
  <p>Here is my VBO init</p>
  
  <pre><code>void loadBufferData()
  {
      glGenBuffers(1, &amp;cubeVBO);
      glBindBuffer(GL_ARRAY_BUFFER, cubeVBO);
      glBufferData(GL_ARRAY_BUFFER, sizeof(cubeVertPoints[0])*3, &amp;cubeVertPoints[0], GL_STATIC_DRAW);
      glEnableVertexAttribArray(0);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(cubeVertPoints[0])*3, (void*)sizeof(GL_FLOAT));
  } 
  </code></pre>
  
  <p>Drawing</p>
  
  <pre><code>    glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glOrtho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f);
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
  
      glBindBuffer(GL_ARRAY_BUFFER, cubeVBO); 
      glEnableVertexAttribArray(0);
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(cubeVertPoints[0])*3, (void*)sizeof(GL_FLOAT));
  
      glDrawArrays(GL_TRIANGLES, 0, 1); 
  
      glDisableVertexAttribArray(0);
      glBindBuffer(GL_ARRAY_BUFFER, 0);
  </code></pre>