I come from one problem onto the next one very quickly it seems.
I have never had a problem like this one before, and I don't think the reason is as stupid as the last one (though I could definitely be wrong).
Anyways, when I try to release stored mesh data in my program I am given an unhandled exception (again). The debugger tells me it roots back to IUnknown, specifically I get this error:
Here is the code for the class where the destructor is being called in which this error is generated:__vfptr CXX0030: Error: expression cannot be evaluated
I am getting the error from the line:Code:class MeshContainer { private: vector<Mesh *> MeshList; public: MeshContainer() {} ~MeshContainer() { if(MeshList.size() > 0) { for(DWORD i=0; i<MeshList.size(); i++) { if(MeshList[i]->MeshData != NULL) { MeshList[i]->MeshData->Release(); MeshList[i]->MeshData = NULL; } delete MeshList[i]; } MeshList.clear(); } } int DrawMesh(DWORD dwMeshID); int LoadMesh(IDirect3DDevice9* &g_pd3dDevice, int iMeshNum); };
When I reach there, the program crashes.Code:MeshList[i]->MeshData->Release();
Here is the mesh structure for reference:
And since I don't want to give to little like last time...Code:struct Mesh { DWORD dwID; DWORD dwNumSubsets; ID3DXMesh* MeshData; Mesh() { dwID = 0; dwNumSubsets = 0; MeshData = NULL; } };
Here is the wrapper class which the MeshContainer class is used in:
Here is the initialization of that wrapper class elsewhere:Code:class ResourceCache { private: friend class CObjectManager; MaterialContainer *Materials; TextureContainer *Textures; MeshContainer *Meshes; public: ResourceCache() { Materials = new MaterialContainer(); Textures = new TextureContainer(); Meshes = new MeshContainer(); } ~ResourceCache() { delete Materials; delete Textures; delete Meshes; } int DrawMesh(DWORD dwMeshID) { return Meshes->DrawMesh(dwMeshID); } int CreateMesh(LPDIRECT3DDEVICE9 &g_pd3dDevice, int iMeshNum) { return Meshes->LoadMesh(g_pd3dDevice, iMeshNum); } };
And finally, here is the deletion statement for that wrapper class object:Code:ResourceCache* ResourceList = new ResourceCache();
Here is the function in which I create the mesh data:Code:delete ResourceList;
I am using MSVC++ 2005 EE (still). I'm not sure what the best way to explain the problem is. All I know is, I can't access the MeshData->Release() function successfully. This is a pain and it shouldn't be. I'm stumped (again). If something needs further clarification, just ask and I'll try to explain better.Code:int MeshContainer::LoadMesh(IDirect3DDevice9* &g_pd3dDevice, int iMeshNum) { Mesh *TempMesh = new Mesh(); switch(iMeshNum) { case MESH_TEAPOT: // Create a Teapot if(FAILED(D3DXCreateTeapot(g_pd3dDevice, &TempMesh->MeshData, 0))) return false; TempMesh->dwNumSubsets = 0; TempMesh->dwID = 0; break; default: return false; break; } MeshList.push_back(TempMesh); return true; }
Thanks in advance....



LinkBack URL
About LinkBacks
. 


