Hi everyone,
I'm having a problem with a certain part of my program - I think it's something to do with a vertex declaration. Basically, I have the following code to calculate a tangent frame for normal mapping:
D3DVERTEXELEMENT9 elements[] =
{
{ 0, sizeof( float ) * 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
{ 0, sizeof( float ) * 3, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
{ 0, sizeof( float ) * 6, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
{ 0, sizeof( float ) * 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 },
{ 0, sizeof( float ) * 15, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 },
D3DDECL_END()
};
LPD3DXMESH tempMesh = NULL;
texturedMesh->CloneMesh(D3DXMESH_MANAGED, elements, renderdev, &tempMesh);
//Continue to calculate the tangent frame for the mesh...
The problem is that when I close the program, it triggers a breakpoint, which corresponds to a crash when I run the program outside of Visual Studio. The crash happens after I clean everything and release everything. I tried putting a breakpoint on every line in my cleanup routine, and even the last line of code in the program (return Msg.wParam;) and it still happens after this. The thing is, when I don't call my function to create a tangent frame, and hence don't use the above vertex declaration, the crash doesn't happen, so I guess it's something to do with that. What's the proper procedure for cleaning up after myself in this situation? There's no output in the debug window either, apart from some 'memory still allocated' errors.
Thanks!