modified to port from WWDC2012 OpenGLScroller