Int arrays in intbuffer for Android OpenGL ES 1.0?

I recently read an article on Badlogicgames.com about speeding up the process of adding information to vertex buffers (or any other intbuffer), and this increased the speed of my project, but I did not quite understand

"Note that IntBuffer.put (int [] src) did not address the issue"

. Is it possible to pass an int [] array to IntBuffer to get an increase in speed if you don't need floating point numbers? Every time I try to put int [] in the buffer; nothing is displayed ...

Here is an example of my current use:

dMesh[i].putVertexBuffer(coords); //function being called public void putVertexBuffer(int[] input) //actual function { ByteBuffer tC = ByteBuffer.allocateDirect(input.length *4); tC.order(ByteOrder.nativeOrder()); _vertexBuffer = tC.asIntBuffer(); _vertexBuffer.put(input); _vertexBuffer.position(0); } 

Now, if the coords int arrays are filled with variables that were floating point numbers converted to integers using "Float.floatToIntBits (float value)"; this is fine ... but the array of standard integers shows nothing ... But if I just have an array of float [] and change "asIntBuffer ()" to "asFloatBuffer ()", does it work? I am embarrassed. Is a conversion required? Thank you in advance to everyone who gives an idea.

Quick edit: I almost forgot ... this is the article I referenced: http://www.badlogicgames.com/wiki/index.php/Direct_Bulk_FloatBuffer.put_is_slow

+4
source share
2 answers

You are not using an int array with the GL_FLOAT parameter for the type in the glVertexPointer call, are you? In this case, I would not wonder about the behavior. When using ints as vertex routes, be sure to use the GL_INT type as the type parameter in glVertexPointer (or any such attribute array function).

0
source

When you tried to use ints, did you also change the code that the array used to use ints instead of float? Here I had all kinds of problems.

Perhaps my previous question / answer helps - it is in this area:

Passing java.nio.IntBuffer function to C in Android game

+1
source

All Articles