public static InnerPickableRenderer GetRenderer(
this IBufferable model,
AttributeMap attributeMap,
string positionNameInIBufferable,
params GLState[] switches)
{
if (model == null || attributeMap == null || string.IsNullOrEmpty(positionNameInIBufferable))
{ throw new ArgumentNullException(); }
AttributeMap map = null;
foreach (AttributeMap.NamePair item in attributeMap)
{
if (item.NameInIBufferable == positionNameInIBufferable)
{
map = new AttributeMap();
map.Add(item.VarNameInShader, item.NameInIBufferable);
break;
}
}
if (map == null) { throw new Exception(string.Format("No matching variable name in shader for [{0}]", positionNameInIBufferable)); }
if (model.UsesZeroIndexBuffer())
{
return new ZeroIndexRenderer(model, PickingShaderHelper.GetShaderCodes(), map, positionNameInIBufferable, switches);
}
else
{
return new OneIndexRenderer(model, PickingShaderHelper.GetShaderCodes(), map, positionNameInIBufferable, switches);
}
}