Question

I am learning some OpenGLES2 tutorials for Android. All of the examples make use of direct buffers to transfer the 3D geometry to the graphic card. The FloatBuffers are used for vertices, normals and colors and the CharBuffer is used for indices.

When it comes to draw the entities or send them to the VBOs the first thing we need is to determine the number of elements in the buffers. And I am a little confused about how to do it, because some tutorials make use of limit() method while other tutorials use capacity(). And here is the question:

What method of FloatBuffer and CharBuffer should I use to determine the number of elements in the buffer?

Was it helpful?

Solution

some tutorials make use of limit() method

They are correct.

while other tutorials use capacity().

They are wrong. That would only be correct if the buffer was full.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top