views:

193

answers:

1

I'm creating an effect using

hr = D3DXCreateEffectFromFile( g_D3D_Device, shaderPath.c_str(), macros, NULL, 0, NULL, &pEffect, &pBufferErrors );

I would like to get all the uniforms that this shader is using. In OpenGL I used glGetActiveUniform and glGetUniformLocation to get constant's size, type, name etc. Is there a D3DX9 equivalent function?

Thanks!

+1  A: 
D3DXHANDLE handle = m_pEffect->GetParameterByName( NULL, "Uniform Name" );
if ( handle != NULL )
{
    D3DXPARAMETER_DESC desc;
    if ( SUCCEEDED( m_pEffect->GetParameterDesc( handle, &desc ) ) )
    {
        // You now have pretty much all the details about the parameter there are in "desc".
    }
}

You can also iterate through each parameter by doing the following:

UINT index = 0;
while( 1 )
{
    D3DXHANDLE handle = m_pEffect->GetParameter( NULL, index );
    if ( handle == NULL )
        break;

    // Get parameter desc as above.
    index++;
}
Goz