Archive for May, 2010

Sane replacement for GLSurfaceView

May 1, 2010

I’ve been asked several times about my implementation of OpenGL ES on top of Android’s SurfaceView so I’m posting it here for easier access 🙂 And maybe someone finds it useful by googling.

A few words about why did I bother in the first place? First, I wanted to control the main game loop by myself and don’t rely on GLSurfaceView’s callbacks. Doing it this way allowed me to have a much better code architecture and is more robust as I can *really* control when and what it does. My version does the same thing in 200 lines of code instead of 1350 and can actually be understood by human beings. That brings us to the second reason: I was experiencing weird bugs and had to debug my GL rendering code. Tracing the issue I ended up at EGL level. To this day I don’t know what was really the problem as GLSurfaceView is an abomination. It doesn’t have a proper separation of responsibilities in its thirteen internal classes, the logic is horribly convoluted… let’s say initially I started to refactor it into something understandable but after a few hours just gave up and wrote my own implementation. In a single class. Simple and working one. Nuff said 🙂

(more…)