| Subcribe via RSS

Gonp, An Android Saga: Part I

April 14th, 2010 | 3 Comments | Posted in Gonp Saga

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.

Tags: , , , , , ,
  • about me

    I'm Paulo Ragonha, a brazilian hobbyist game developer, who enjoys playing with technology on my free time, my (current) main language is Java so you will probably see a lot of stuff about it in here, I also occasionally talk abut random stuff... and will probably post a "game" every once in a while.
    Thanks for passing by!


  • twitter