port gl code to stage3d