What do you guys think about using vertex arrays like what I have below?
This would get called each time my display() method is called, which I believe is each time my mouse moves just a single pixel to rotate the model. So dragging would call it quite often. Specifically, is it ok to use vertex arrays the way I have below, where I populate it w/ an individual triangle, and draw it … or should I build a vertex array the size of my complete triangle list and then draw that.
What I have now sure seems like a lot of loop iterations to go through (10,000 * each triangle side) each time my mouse moves just one pixel. I’m starting to think this isn’t the correct way to use vertex arrays. See how I draw individual triangles. I’m wondering if this is why my model doesn’t move as smooth as it should/could.
Code is cut down just for understanding.
buffer = BufferUtils.newFloatBuffer(9);
// hashmap normally has between 10,000 and 100,000 line edges in it.
Iterator eKeyIter = myHashMap.keySet().iterator();
while (eKeyIter.hasNext()) {
// ...
for (int i = 0; i < TRIANGLE_CNT; i++) {
// ...
vElementsBuffer.put(idx++, (float) getX());
vElementsBuffer.put(idx++, (float) getY());
vElementsBuffer.put(idx++, (float) getZ());
}
gl.glVertexPointer(3, GL.GL_FLOAT, 0, vElementsBuffer);
gl.glDrawArrays(GL.GL_TRIANGLES, 0, 8);
}