views:

1133

answers:

2

I saw this Google IO session: http://code.google.com/intl/iw/events/io/2009/sessions/WritingRealTimeGamesAndroid.html
He says that the draw_texture function is the fastest and VBO is 2nd faster.
But I don't understand how to use it(the draw_texture method or the VBO way).

Any suggestion?

+3  A: 

The source code for the sprite method test mentioned in the video is available here:
http://code.google.com/p/apps-for-android/source/browse/#svn/trunk/SpriteMethodTest

Here is an example from that where a VBO is used:
http://code.google.com/p/apps-for-android/source/browse/trunk/SpriteMethodTest/src/com/android/spritemethodtest/Grid.java#237

Here is an example from that where the draw texture extension is used:
http://code.google.com/p/apps-for-android/source/browse/trunk/SpriteMethodTest/src/com/android/spritemethodtest/GLSprite.java#70

One thing to watch out for, however, is that the draw texture extension is actually not the fastest for all games using sprites. Many games have groups of sprites that all share the same render state, for example. In that case it is much faster to put all sprites with the same render state in the same buffer and draw them with the same draw command. The draw texture command doesn't allow this. With the draw texture command you have to call it once per sprite.

This is the reason that atlas textures are often used. An atlas texture is a single bound texture object that has many different images in it. You can draw sprites with different images that way without having to bind to a different texture object. All you do is have them use different texture coordinates into the atlas texture. If the other render state is the same as well, such as the blending function needed, then you can draw the sprites together for better performance.

Lance Nanek
+2  A: 

Here are some great Android OpenGL ES working examples.

http://code.google.com/p/android-gl/

sadboy