本文整理汇总了C++中LPD3DXMESH::Optimize方法的典型用法代码示例。如果您正苦于以下问题:C++ LPD3DXMESH::Optimize方法的具体用法?C++ LPD3DXMESH::Optimize怎么用?C++ LPD3DXMESH::Optimize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPD3DXMESH
的用法示例。
在下文中一共展示了LPD3DXMESH::Optimize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: memcpy
HRESULT CMyD3DApplication::OptimizeMeshData
(
LPD3DXMESH pMeshSysMem,
LPD3DXBUFFER pAdjacencyBuffer,
DWORD dwOptFlags,
SMeshData *pMeshData
)
{
HRESULT hr = S_OK;
LPD3DXBUFFER pbufTemp = NULL;
DWORD iMaterial;
// attribute sort - the un-optimized mesh option
// remember the adjacency for the vertex cache optimization
hr = pMeshSysMem->Optimize( dwOptFlags|D3DXMESH_SYSTEMMEM,
(DWORD*)pAdjacencyBuffer->GetBufferPointer(),
NULL, NULL, NULL, &pMeshData->m_pMeshSysMem);
if( FAILED(hr) )
goto End;
pMeshData->m_cStripDatas = m_dwNumMaterials;
pMeshData->m_rgStripData = new SStripData[pMeshData->m_cStripDatas];
if (pMeshData->m_rgStripData == NULL)
{
hr = E_OUTOFMEMORY;
goto End;
}
for (iMaterial = 0; iMaterial < m_dwNumMaterials; iMaterial++)
{
hr = D3DXConvertMeshSubsetToSingleStrip(pMeshData->m_pMeshSysMem, iMaterial,
D3DXMESH_IB_MANAGED, &pMeshData->m_rgStripData[iMaterial].m_pStrips,
&pMeshData->m_rgStripData[iMaterial].m_cStripIndices);
if (FAILED(hr))
goto End;
hr = D3DXConvertMeshSubsetToStrips(pMeshData->m_pMeshSysMem, iMaterial,
D3DXMESH_IB_MANAGED, &pMeshData->m_rgStripData[iMaterial].m_pStripsMany,
NULL, &pbufTemp, &pMeshData->m_rgStripData[iMaterial].m_cStrips);
if (FAILED(hr))
goto End;
pMeshData->m_rgStripData[iMaterial].m_rgcStripLengths = new DWORD[pMeshData->m_rgStripData[iMaterial].m_cStrips];
if (pMeshData->m_rgStripData[iMaterial].m_rgcStripLengths == NULL)
{
hr = E_OUTOFMEMORY;
goto End;
}
memcpy(pMeshData->m_rgStripData[iMaterial].m_rgcStripLengths, pbufTemp->GetBufferPointer(), sizeof(DWORD)*pMeshData->m_rgStripData[iMaterial].m_cStrips);
}
End:
SAFE_RELEASE(pbufTemp);
return hr;
}