Ported code to openGL. Still todo: subwindows.