本文整理汇总了C++中LPD3DXCONSTANTTABLE::GetConstantByName方法的典型用法代码示例。如果您正苦于以下问题:C++ LPD3DXCONSTANTTABLE::GetConstantByName方法的具体用法?C++ LPD3DXCONSTANTTABLE::GetConstantByName怎么用?C++ LPD3DXCONSTANTTABLE::GetConstantByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPD3DXCONSTANTTABLE
的用法示例。
在下文中一共展示了LPD3DXCONSTANTTABLE::GetConstantByName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: modelShaderApply
//-----------------------------------------------------------------------
void CEnvironmentMap::modelShaderApply(OwnMatrix4x4 *pModelMtx /*= NULL*/, bool bRenderEnvMappedMesh)
{
LPD3DXCONSTANTTABLE constable = mVtxConstTable;
OwnMatrix4x4 modelMtx, viewProjMtx, modelViewProjMtx;
if (NULL == pModelMtx)
modelMtx.setIdentity();
else
modelMtx = *pModelMtx;
viewProjMtx.setMultiply(mCamera->mViewTrans, mCamera->mProjectionTrans);
modelViewProjMtx.setMultiply(modelMtx, viewProjMtx);
HRESULT hr;
D3DXHANDLE handle;
D3DXHANDLE modelViewProj = mVtxConstTable->GetConstantByName(0, "u_ModelViewProjMatrix");
hr = mVtxConstTable->SetMatrix(mD3DDevice, modelViewProj, (D3DXMATRIX*)&modelViewProjMtx);
D3DXHANDLE u_ModelMatrix = constable->GetConstantByName(0, "u_ModelToWorld");
hr = constable->SetMatrix(mD3DDevice, u_ModelMatrix, (D3DXMATRIX*)&modelMtx);
LPD3DXCONSTANTTABLE pixConstable = mPxlConstTable;
float value = bRenderEnvMappedMesh ? 0.5f : 0;
D3DXHANDLE reflectivity = pixConstable->GetConstantByName(0, "$reflectivity");
hr = pixConstable->SetFloat(mD3DDevice, reflectivity, value);
}
示例2:
bool CD3D9HLSLMaterialRenderer::setVariable(bool vertexShader, const c8* name,
const f32* floats, int count)
{
LPD3DXCONSTANTTABLE tbl = vertexShader ? VSConstantsTable : PSConstantsTable;
if (!tbl)
return false;
// currently we only support top level parameters.
// Should be enough for the beginning. (TODO)
D3DXHANDLE hndl = tbl->GetConstantByName(NULL, name);
if (!hndl)
{
core::stringc s = "HLSL Variable to set not found: '";
s += name;
s += "'. Available variables are:";
os::Printer::log(s.c_str(), ELL_WARNING);
printHLSLVariables(tbl);
return false;
}
HRESULT hr = tbl->SetFloatArray(pID3DDevice, hndl, floats, count);
if (FAILED(hr))
{
os::Printer::log("Error setting float array for HLSL variable", ELL_WARNING);
return false;
}
return true;
}
示例3: lightShaderConfig
//-----------------------------------------------------------------------
void CEnvironmentMap::lightShaderConfig()
{
HRESULT hr;
D3DXHANDLE handle;
Material material;
material.Ke = D3DXVECTOR3(0, 0, 0);
material.Ka = D3DXVECTOR3(0, 0, 0);
material.Kd = D3DXVECTOR3(1, 1, 1);
material.Ks = D3DXVECTOR3(1, 1, 1);
material.shininess = 5;
Light light;
light.position = D3DXVECTOR3(-10, 0, -10);
light.color = D3DXVECTOR3(0, 1, 0);
LPD3DXCONSTANTTABLE constable = mVtxConstTable;
D3DXHANDLE u_Material = constable->GetConstantByName(0, "u_Material");
hr = constable->SetValue(mD3DDevice, u_Material, &material, sizeof(material));
D3DXHANDLE u_Light = constable->GetConstantByName(0, "u_Light");
hr = constable->SetValue(mD3DDevice, u_Light, &light, sizeof(light));
}