adapted from patch by Matthias Schiffer.
patch by Mahesh Bodapati and Jaydeep Patil of Imagination Technologies.