How to work around performance issues with Buffer.put () and Android OpenGL


It is a Java issue in general, though in this particular case I am using Vertex Arrays in Android for OpenGL. To use this basic GL system, you must use Java's Buffer system in native allocation mode. This is very slow on Java. And roughly 40-50% of my entire application's time is spent inside of buffer.put().

Is there any way to speed this up while staying in Java (ie, don't use the native sdk)?

Avoid allocations in general. Use a pool of buffers and juggle them around as needed. You can have a few standard sizes and waste a few bytes at the end in exchange for performance. Also, when using OpenGL you typically don't need to rewrite your buffers every frame (unless you do extensive skinning or animation?). Normally, you have your pre-baked arrays, transform objects using matrices, and that's it.