revised base code for texture mapping