Taglibgdx

Android libgdx ShaderAssetLoader & StillModelLoader

I totally love how libgdx brings a lot of interfaces for your application to connect to the graphics library. For instance the asset manager is really thought through well in particular. It has some really useful methods like Assets.manager.getProgress(). Especially since you can easily write your own asset loader and be able to utilize the loading progress in your app.

1) Simply add your loader to the asset manager at some point.

2) load your assets at required places, e.g. loading screen
(Note: SHADER_PHONG = “data/Graphics/Shader/Phong”; and MODEL_TEAPOT = “data/Graphics/Shader/teapot.obj”)

3) get your shader or model wherever you need them

4) free the resource by unloading when you’re done with them (e.g. disposing your app; changing screens)

That’s the shader asset loader for loading custom shaders in libgdx. (Note: adapt your extensions)

And here is the StillModel loader for loading 3D meshes:

Conclusion: assets are handled well in libgdx :D

libgdx and BufferUtils.copy()

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

before

actually before you do anything with libgdx classes, since they are using pre-compiled code.