use glFinish() instead of glFlush()