Fix eglSwapBuffers

Checks now whether ctx was initialized and not lost.
Does a glFlush before returning.
And returns success codes from function.

See http://www.khronos.org/registry/egl/sdk/docs/man/xhtml/eglSwapBuffers.html