Gonp, An Android Saga: Part I
Today myself and a couple of friends (Renato Besen and Vitor Pelizza) started on a saga to develop a game on Android, there is not much to see or do after our approximately three hours of work but of what is on the screenshot bellow:
A green square, composed of 2 triangles and 4 points. Which might not seem much at a first glance, but there was a lot of learning in the process.
Through the development we followed loosely this tutorial series, but as good questioners as we are, we quickly started to put some query upon some of the tutorial’s solutions. For instance, why does the buffer creation needs all this code:
ByteBuffer ibb = ByteBuffer.allocateDirect(_nrOfVertices * 2);
ibb.order(ByteOrder.nativeOrder());
_indexBuffer = ibb.asShortBuffer();
_indexBuffer.put(_indicesArray);
When we thought it could be done with something like this:
ShortBuffer _indexBuffer = ShortBuffer.wrap(_indicesArray);
After seeing the app crash on start we understood that all buffers used by OpenGL ES need to be of the device’s native byte order, which is not the default order when creating a Buffer through the wrap method. To solve this more elegantly we created a factory for native byte order buffers.
Next up was drawing our Player(the square), but since OpenGL ES does not support QUADs, it would need to be composed of two triangles. After figuring out how the glVertexPointer and glDrawElements methods work, we finally made our Player class render on the screen:
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexes);
gl.glDrawElements(GL10.GL_TRIANGLES, indexes.capacity() …
On the first line we tell OpenGL wich are the points that it needs to render, next we pass an array containing the order that they need to be drawn.
That is it for now, but you can follow our progress through the project’s Redmine or by checking out the code at the git repository.
Update: Moved the repository to github.

April 14th, 2010 at 10:14 pm
No pain, no gain
looking forward for the next coding session
April 26th, 2010 at 2:28 pm
Caramba!! não sabia que ainda estava no ar!!!
grande abraço!
July 13th, 2010 at 6:16 pm
Yoooo
Still working on Android? I wanna get in that boat! hehe