bool CModel::OptimizeMesh(LPD3DXMESH *lpMesh){
HRESULT hr = S_OK;
DWORD *pAdjacencyIn = NULL;
LPD3DXMESH tMesh = *lpMesh;
pAdjacencyIn = new DWORD[tMesh->GetNumFaces()*sizeof(DWORD)*3];
hr = tMesh->GenerateAdjacency(1e-6f, pAdjacencyIn);
if( FAILED(hr) )
return false;
hr = D3DXCleanMesh( D3DXCLEAN_SIMPLIFICATION , tMesh, pAdjacencyIn, &tMesh, pAdjacencyIn, NULL);
if( FAILED(hr) )
return false;
SAFE_DELETE(pAdjacencyIn);
return true;
}
[SOLVED]Strange memory leaks
i've found some strange memory leaks:
if i comment out D3DXCleanMesh, there are no leaks. This is the output at the end of the program:
The thread 'Win32 Thread' (0xa4) has exited with code 0 (0x0).
D3DX: MEMORY LEAKS DETECTED: 2 allocations unfreed (5436 bytes)
Any advices?
[Edited by - b3rs3rk on December 12, 2006 8:17:54 AM]
I would suggest wrapping all of the COM interfaces you use from DirectX in a com pointer. CComPtr will manage the reference counting of the interfaces automagically.
Dave
#include <atlbase.h>CComPtr<IDirect3DVertexBuffer9> Direct3DVertexBufferetc...
Dave
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement