title: Why is glDrawElements giving me GL_OUT_OF_MEMORY?
body: <p>I'm only drawing 4 vertices. I'm trying to render a simple quad using <code>glDrawElements</code>, but nothing seems to work. I've written identical code in Java as well, and it works. This, however, does not.</p>
  
  <p>Here's the drawing code:</p>
  
  <pre><code>glUseProgram(mProgram);
  
  
  glBindBuffer(GL_ARRAY_BUFFER, mBuffers[0]);
  glEnableVertexAttribArray(mPosAttr);
  glVertexAttribPointer(mPosAttr, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
  
  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mBuffers[1]);
  if (er == 0){ er = glGetError(); std::cout&lt;&lt;gluErrorString(er)&lt;&lt;std::endl; }
  glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, (void*)0);
  
  
  glDisableVertexAttribArray(mPosAttr);
  glBindBuffer(GL_ARRAY_BUFFER, 0);
  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
  glUseProgram(0);
  </code></pre>
  
  <p>I've left out useless things like <code>glUniform__</code> calls, I get the same result either way. Anyway, this prints "no error" the first time and then "out of memory" the second. That means it is most definitely caused by glDrawElements.</p>
  
  <p>Why is this happening? What would fix it? Should I provide more code?</p>