opengl: Fixed threading issue with OpenGL