Full code in a wordpad file here:
http://www.kryolinth.com/gamecodeV1_...estroyMesh.rtf
Real simple. InitGeometry(); is called when you press the C key. "C" for "Create stuff" you can think of it as. Upon pressing the D key, it calls DestroyGeometry(); which is supposed to delete meshes, tetxures, and materials.
The problem? Everything compiles fine, however I get an error when I press D to call DestroyGeometry.
Code:
VOID DestroyGeometry(int NUMOFOBJECTS)
{
int w;
for(w=0;w<NUMOFOBJECTS;w++)
{
if( m_pMeshMaterials[w] )
delete[] m_pMeshMaterials[w];
if( m_pMeshTextures[w] )
{
for( DWORD i = 0; i < m_dwNumMaterials[w]; i++ )
{
if( m_pMeshTextures[w][i] )
m_pMeshTextures[w][i]->Release();
}
delete[] m_pMeshTextures[w];
}
if( m_pMesh[w] )
m_pMesh[w]->Release();
}
}
I load in two meshes with InitGeometry(2); The "2" tells the InitGeometry loop how many times to loop so it loads in 2 objects. So I use the same method with DestroyGeometry. DestroyGeometry(2); so it loops through the FOR loop twice for both objects.
I did read that you have to be careful when deleting things, so I guess it's good that I'm asking about this before my computer blows up.
I've messed around with this a bit.
It likes this line: delete[] m_pMeshMaterials[w];
But it doesn't like this one: m_pMeshTextures[w][i]->Release();
That's where it messes up. The debugger doesn't seem to yield any useful information.