我正在用一个特效
hr = D3DXCreateEffectFromFile( g_D3D_Device,
shaderPath.c_str(),
macros,
NULL,
0,
NULL,
&pEffect,
&pBufferErrors );我想要得到这个着色器正在使用的所有制服。在OpenGL中,我使用glGetActiveUniform和glGetUniformLocation来获取常量的大小、类型、名称等。有没有D3DX9等价的函数?
发布于 2009-07-14 08:24:19
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".
}
}您还可以通过执行以下操作遍历每个参数:
UINT index = 0;
while( 1 )
{
D3DXHANDLE handle = m_pEffect->GetParameter( NULL, index );
if ( handle == NULL )
break;
// Get parameter desc as above.
index++;
}发布于 2015-01-23 23:20:19
使用
m_pEffect->获取参数( NULL,索引);
在while (1)循环中将导致
D3DX: ID3DXEffect::D3DX参数:无效索引
警告。
所以我们可以使用D3DXEFFECT_DESC结构来找出一个效果有多少个参数。
如下所示:
D3DXEFFECT_DESC fx_desc;
g_pEffect->GetDesc(&fx_desc);
for (UINT index=0;index<=fx_desc.Parameters;index++)
{
D3DXHANDLE handle = g_pEffect->GetParameter( NULL, index );
if ( handle == NULL )
break;
D3DXPARAMETER_DESC param_desc;
if ( S_OK == ( g_pEffect->GetParameterDesc( handle, ¶m_desc ) ) )
{
//check the details about the parameter in param_desc
}
}https://stackoverflow.com/questions/1122203
复制相似问题