porting code to GL