modified code to make run with OpenGL and new renderer