Пример #1
0
//-----------------------------------------------------------------------------
void CPUTModelDX11::SetSubMaterials(UINT ii, CPUTMaterial **pMaterial)
{
    CPUTModel::SetSubMaterials(ii, pMaterial);
    HEAPCHECK;

    // Can't bind the layout if we haven't loaded the mesh yet.
    CPUTMeshDX11 *pMesh = (CPUTMeshDX11*)mpMesh[ii];
    D3D11_INPUT_ELEMENT_DESC *pDesc = pMesh->GetLayoutDescription();

    // Release the old input layouts and delete the layout array.
    if( mpInputLayout[ii] )
    {
        for( UINT jj=0; jj<mpSubMaterialCount[ii]; jj++ )
        {
            SAFE_RELEASE(mpInputLayout[ii][jj]);
        }
        SAFE_DELETE(mpInputLayout[ii]);
    }

    mpInputLayout[ii] = new ID3D11InputLayout*[mpSubMaterialCount[ii]];
    memset( mpInputLayout[ii], 0, sizeof(ID3D11InputLayout*) * mpSubMaterialCount[ii] );
    for( UINT jj=0; jj<mpSubMaterialCount[ii]; jj++ )
    {
        if( pDesc )
        {
            pMesh->BindVertexShaderLayout((CPUTMaterialDX11*)mpMaterial[ii][jj], &mpInputLayout[ii][jj]);
            HEAPCHECK;
        }
    }
}
Пример #2
0
// Set the material associated with this mesh and create/re-use a
//-----------------------------------------------------------------------------
void CPUTModelDX11::SetMaterial(UINT ii, CPUTMaterial *pMaterial)
{
    CPUTModel::SetMaterial(ii, pMaterial);

    // Can't bind the layout if we haven't loaded the mesh yet.
    CPUTMeshDX11 *pMesh = (CPUTMeshDX11*)mpMesh[ii];
    D3D11_INPUT_ELEMENT_DESC *pDesc = pMesh->GetLayoutDescription();
    if( pDesc )
    {
        pMesh->BindVertexShaderLayout(pMaterial, mpMaterial[ii]);
    }
}