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
source share