refactored some of the OpenGL interop code