Original Post
Hello, I am trying to optimize my mesh files, however, I can't get the adjacency buffer to work. I get the folllowing error message every time I use the GenerateAdjacency command: First-chance exception at 0x77c17631 in 2d.exe: 0xC0000005: Access violation writing location 0x00376000. Unhandled exception at 0x77c17631 in 2d.exe: 0xC0000005: Access violation writing location 0x00376000. Here is the code I use Any help in solving this would be greatly appreciated
Create an adjacency buffer
LPD3DXBUFFER pAdjacencyBuffer = NULL;
D3DXCreateBuffer( g_pMesh[m]->GetNumFaces() * 3, &pAdjacencyBuffer );
// Using a vertex positional tolerance of 0.0f, ask the mesh for its
// adjacency information.
g_pMesh[m]->GenerateAdjacency( 0.0f, (DWORD*)pAdjacencyBuffer->GetBufferPointer() );
// Now, tell the mesh to attempt an optimization based on that
// adjacency information.
if(FAILED(g_pMesh[m]->OptimizeInplace( D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_COMPACT | D3DXMESHOPT_VERTEXCACHE | D3DXMESHOPT_STRIPREORDER, (DWORD*)pAdjacencyBuffer->GetBufferPointer(), NULL, NULL, NULL ) )
{
MessageBox(NULL, "Could not optimize" ,meshnaam[m] , MB_OK);
return E_FAIL;
}
if( pAdjacencyBuffer != NULL )
pAdjacencyBuffer->Release();