Pass format to the QGLWidget and use atomic instead of mutex.