title: glDrawElements crashing
body: <p>During every call to glDrawElements, my graphics driver crashes/freezes and recovers after a few seconds (Windows 7 Timeout Detection/Recovery). glGetError() always returns GL_NO_ERROR.</p>
  
  <p>Edit: Just to be clear about what exactly happens: the first time glDrawElements is called, my computer freezes for 5-10 seconds, then the screen goes black for a few more seconds, then it recovers and Windows gives me a message: "Display driver stopped responding and has recovered". My program keeps running, but it's stuck in glDrawElements.</p>
  
  <p><strong>Update</strong>: Adding a call to glFlush() just before glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) makes it work. I don't understand why.</p>
  
  <p>Here's my code, somewhat simplified and without error checking. Am I doing anything wrong?</p>
  
  <pre><code>struct Vertex
  {
      float pos[3];
      float color[3];
  };
  
  struct Tri
  {
      unsigned int idxs[3];
  };
  
  // ...
  
  GLuint m_vbo;
  GLuint m_ibo;
  
  std::vector&lt;Vertex&gt; m_verts;
  std::vector&lt;Tri&gt; m_faces;
  
  // ...
  
  glGenBuffers(1, &amp;m_vbo);
  
  Vertex* vBuf = &amp;(m_verts[0]);
  unsigned int vboSize = sizeof(vBuf[0]) * m_verts.size();
  
  glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
  glBufferData(GL_ARRAY_BUFFER, vboSize, vBuf, GL_STATIC_DRAW);
  
  glGenBuffers(1, &amp;m_ibo);
  
  unsigned int* iBuf = (unsigned int*) (&amp;(m_faces[0]));
  unsigned int iboSize = sizeof(iBuf[0]) * (m_faces.size() * 3);
  
  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ibo);
  glBufferData(GL_ELEMENT_ARRAY_BUFFER, iboSize, iBuf, GL_STATIC_DRAW);
  
  // ...
  
  // this line fixes it
  // glFlush();
  
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glUseProgram(someShaderProgram);
  
  // ...
  
  glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ibo);
  
  // the attribute locations are queried using glGetAttribLocation in the real code
  glEnableVertexAttribArray(1);
  glVertexAttribPointer
      (1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)(0));
  
  glEnableVertexAttribArray(0);
  glVertexAttribPointer
      (0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)(3*sizeof(float)));
  
  // doesn't get past this line
  glDrawElements(GL_TRIANGLES, m_faces.size()*3, GL_UNSIGNED_INT, 0);
  
  // ...
  
  glfwSwapBuffers();
  </code></pre>