当前位置: 首页>>代码示例>>C++>>正文


C++ LPD3DXMESH::Optimize方法代码示例

本文整理汇总了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;
}
开发者ID:grakidov,项目名称:Render3D,代码行数:57,代码来源:optimizedmesh.cpp


注:本文中的LPD3DXMESH::Optimize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。