updated to be more compliant to WebGL spec