title: Draw many of the same object quickly in OpenGL
body: <p>So I'm working on a game and I need to draw a lot of the same object. Same shape, same size, same color, just different locations.</p>
  
  <p>Right now my setup is like this.</p>
  
  <p>I have some class <code>Renderer</code> where object that want to draw on the screen can call <code>static void addVertex(float x, float y, float z);</code> which will store the vertex into an <code>std::vector</code>. When everyone is done drawing <code>static void draw();</code> in <code>Renderer</code> is called where everything is stuffed into a VBO and drawn onto the screen.</p>
  
  <p>draw looks like this:</p>
  
  <pre><code>void Renderer::draw() {
      glBindBufferARB(GL_ARRAY_BUFFER_ARB, _quadID);
      glBufferSubDataARB(GL_QUADS, 0, _vertexBuffer.dataSize(), _vertexBuffer.toArray());
  
      glColorPointer(4, GL_FLOAT, 0, _colorBuffer.toArray());
  
      glEnableClientState(GL_VERTEX_ARRAY);
      glEnableClientState(GL_COLOR_ARRAY);
      glVertexPointer(3, GL_FLOAT, 0, _vertexBuffer.toArray());
  
      glDrawArrays(GL_QUADS, 0, (_vertexBuffer.size() / 3));
      glDisableClientState(GL_VERTEX_ARRAY);
      glDisableClientState(GL_COLOR_ARRAY);
  
      glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
  
      _vertexBuffer.clear();
      _colorBuffer.clear();
  }
  </code></pre>
  
  <p>Where <code>_vertexBuffer</code> and <code>_colorBuffer</code> are of a class <code>template &lt;class T&gt; Buffer</code> which is more or less a managed <code>std::vector&lt;T&gt;</code> for my purposes.</p>
  
  <p>With this setup I can get about 300 things on screen before I start slowing down. Right now everything is a GL_QUAD. Bear in mind I'm a little new to OpenGL, if the above is embarrassing I'm sorry.</p>
  
  <p>How can I improve this to account for like polygons?</p>