While trying to increase the speed of skeleton animations in my android opengl render engine I’ve stumbled uppon some issues with android < v3.0 FloatBuffer.put(). It states the following methods to update the buffers and it speeds:
The same benchmark produced the following timings on a Nexus One with Android 2.2:
- FloatBuffer.put( float value ): 6.876 secs
- FloatBuffer.put(int index, float value): 7.006 secs
- FloatBuffer.put( float[] values ): 6.800 sec
- IntBuffer.put( int[] values): 1.479 secs
- BufferUtils.copy(): 0.067 secs
In order to use the BufferUtils.copy() methode provided in libgdx library you need the gdx.jar, gdx-backend-android.jar, which you should add as library to your android project, and the compiled libs in the right place.
Also call
1 | GdxNativesLoader.load(); |
before
1 2 | // verticesFloatBuffer.capacity() >= vertex_array.length BufferUtils.copy(vertices_array, verticesFloatBuffer.getBuffer(), verticesFloatBuffer.capacity(), 0); |
actually before you do anything with libgdx classes, since they are using pre-compiled code.