Moved code from OpenGLAda to here