title: OpenGL (ES) -- glBindBuffer throws IllegalArgumentException: remaining < size()
body: <p>I've made a buffer of vertices that correctly draw when using glDrawArrays, however they fail to load into a VBO. Here's the code:</p>
  
  <pre><code>
  FloatBuffer circleBuffer = ByteBuffer.allocateDirect(numVertices * 3 *
    4).order(ByteOrder.nativeOrder()).asFloatBuffer();
  
  for (int j = 0; j &lt numVertices; j++) {
    circleBuffer.put((float) (Math.cos(theta)));
    circleBuffer.put((float) (Math.sin(theta)));
    circleBuffer.put(1);
    theta += 2 * Math.PI / (numVertices);
  }
  
  int[] buffer = new int[1];
  int circleIndex=0;  
  gl11.glGenBuffers(1, buffer,0);
  circleIndex = buffer[0];
  gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, circleIndex);
  gl11.glBufferData(GL11.GL_ARRAY_BUFFER, circleBuffer.capacity() * 4,
    circleBuffer, GL11.GL_STATIC_DRAW);</code></pre>
  
  <p>I outputed the capacity of the buffer and it is 105, and the remaining is 0. I also tried reassigning the FloatBuffer as a Buffer. What's wrong here? Thanks!</p>
  
  <hr>
  
  <pre><code>
  ERROR/AndroidRuntime(7127): java.lang.IllegalArgumentException: remaining() &lt size
  ERROR/AndroidRuntime(7127): at com.google.android.gles_jni.GLImpl.glBufferData(Native Method)
  </code></pre>
  
  <p>EDIT -- Solution</p>
  
  <p><pre><code>
  buffer.flip();
  </pre></code></p>