Optimize the rendering procedure in the OpenGL part.

The drawing of the elements is now postponed until we know all of them. A new
class gl_state stores the information needed to draw the element and we can
merge it with an existing element in needed.
Handle the finger events in most classes that used to handle mouse events.