• Create Account

### #ActualNightCreature83

Posted 14 February 2012 - 02:24 AM

Have you tried just using the GetSamplerIndex with the constant name?

thanks a lot.
I add this unpleasant code
handle = pdxVertexConstants->GetConstantByName(NULL, var_name);
if (strcmp(var_name, "xBillboardTexture") == 0)
{
HRESULT res = localDevice->SetTexture(0, baseTexture);
return res;
}

Thats an extremely hardcoded version of setting sampler 0, why?
D3DXHANDLE handle;
handle = pdxVertexConstants->GetConstantByName(NULL, var_name);
if (localDevice && pdxPixelConstants && (handle = pdxPixelConstants->GetConstantByName(NULL, var_name)))

That line doesn't make sense in your original code anyway as you are overwriting handle of a vertex texure with that of a pixel texture. Assignments in an if aren't nice anyway especially when there are more arguments in the condition.
But I have a feeling that just using GetSamplerIndex with your constant name will work as D3DXHANDLES are just strings anyway.

### #1NightCreature83

Posted 14 February 2012 - 02:23 AM

Have you tried just using the GetSamplerIndex with the constant name?

thanks a lot.
I add this unpleasant code
handle = pdxVertexConstants->GetConstantByName(NULL, var_name);
if (strcmp(var_name, "xBillboardTexture") == 0)
{
HRESULT res = localDevice->SetTexture(0, baseTexture);
return res;
}

Thats an extremely hardcoded version of setting sampler 0, why?
[color="#000000"]handle [/color][color="#666600"]=[/color][color="#000000"] pdxVertexConstants[/color][color="#666600"]->[/color][color="#660066"]GetConstantByName[/color][color="#666600"]([/color][color="#000000"]NULL[/color][color="#666600"],[/color][color="#000000"] var_name[/color][color="#666600"]);[/color]
[color="#000088"]if[/color] [color="#666600"]([/color][color="#000000"]localDevice [/color][color="#666600"]&&[/color][color="#000000"] pdxPixelConstants [/color][color="#666600"]&&[/color] [color="#666600"]([/color][color="#000000"]handle [/color][color="#666600"]=[/color][color="#000000"] pdxPixelConstants[/color][color="#666600"]->[/color][color="#660066"]GetConstantByName[/color][color="#666600"]([/color][color="#000000"]NULL[/color][color="#666600"],[/color][color="#000000"] var_name[/color][color="#666600"])))[/color]

That line doesn't make sense in your original code anyway as you are overwriting handle of a vertex texure with that of a pixel texture. Assignments in an if aren't nice anyway especially when there are more arguments in the condition.
But I have a feeling that just using GetSamplerIndex with your constant name will work as D3DXHANDLES are just strings anyway.

PARTNERS