int arrays into intbuffer for Android OpenGL ES 1.0?
I recently read an article on Badlogicgames.com about speeding up the process of adding information into vertex buffers (or any other intbuffer) and it did increase the speed of my project, but I didn't quite understand the
"Noticing the IntBuffer.put( int[] src ) was not affected by the problem"
statement.... Is it possible to feed an int[] array into an IntBuffer to get a speed increase if you have no need for floating point numbers? Every time I try and put an int[] into the buffer; nothing is rendered...
Here is an example of my current usage:
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.pos开发者_Python百科ition(0);
}
Now if the int array "coords" is filled with variables that were floating point numbers converted into integers using "Float.floatToIntBits(float value)"; this is fine... but an Array of standard integers does not show anything... But if I just have a float[] array and change "asIntBuffer()" to "asFloatBuffer()", this works? I'm confused. Is there a conversion required? Thankyou in advance to anyone who gives any insight.
Quick edit: I nearly forgot... this is the article I referenced: http://www.badlogicgames.com/wiki/index.php/Direct_Bulk_FloatBuffer.put_is_slow
When you tried ints, did you also change the code which used the array to consume ints instead of floats? I had all sorts of problems here.
It's possible my previous question/answer helps - it's in this area:
Passing java.nio.IntBuffer to C function in an Android game
You are not using an int array with a parameter of GL_FLOAT
for the type in the glVertexPointer
call, are you? In this case I wouldn't wonder about the behaviour. When using ints as vertex poistions, be sure to use a type of GL_INT
as type parameter in glVertexPointer
(or any such attribute array function).
精彩评论