title: How can I draw multiple vertex array on a single draw call in OpenGL?
body: <p>I want to simulate a bunch of balls' movement. These balls are rendered as 12 vertices with GL_TRIANGLE_FAN. In my design, every ball object maintains an array of its own vertices attributes. However, every time I invoke <code>glDrawElements</code>, it only draws one <code>Vertex Buffer Object</code>. 1000 balls need 1000 draw call. It's not efficient. If I draw points instead of triangle fan, I could draw it as follow:</p>
  
  <pre><code>class Ball
  {
  public:
      GLfloat x, y;
      // ...
  }
  
  Ball balls[] = {Ball(100, 100), Ball(80, 120), ...};
  
  void display()
  {
      glEnableClientState(GL_VERTEX_ARRAY);
      glVertexPointer(2, GL_FLOAT, sizeof(Ball), 0); // stride
  
      glDrawArrays(GL_POINTS, 0, vertex_num);
      //...
  }
  </code></pre>
  
  <p>With <code>stride</code> parameter, I could 'choose' x, y from balls array and skip other members. I wonder how could I do the same thing when every object maintain an array of vertex attributes? Or I should extract all vertex attributes and combine them into a single VBO? But it needs extra code to maintain it and increases the coupling.</p>