Big problem with engine shutdown after loading a mesh file
Posted: Fri Jul 01, 2005 10:44 pm
Hello,
I have a big problem with loading a mesh (or in other words, loading is fine, but the shutdown is not).
When I use this code, everyting works fine:
but the model I want to load is a static mesh, not an animated mesh. So I want to use the "addMeshSceneNode" method:
This way it also works - until I want to close my program/shutdown the engine. When I click on the close button of my window, the destructor calls "m_pDevice->drop();" to shutdown Irrlicht. But then (and only with the "addMeshSceneNode", not with the "addAnimatedMeshSceneNode"), Visual Studio (I use version 2003) stops and displays a message with an "Unhandled Exception at.... " (no more information). The compiler shows the file "iunknown.h" with this code:
// *** This is where the compiler stops and pop up the error message (unhandled exception).
So the error must have to do with a reference counter, maybe something where the engine needs a ->drop() or something (when I don't destroy the engine/no call to device->drop()) the error doesn't appear)
Please, can anyone help? I just don't know what I'm doing wrong. Is my "addMeshSceneNode"-codeline wrong? Or must I use ->drop() on any object?
Thanks a lot for your help!
I have a big problem with loading a mesh (or in other words, loading is fine, but the shutdown is not).
When I use this code, everyting works fine:
Code: Select all
IAnimatedMesh* mesh = sceneManager->getMesh("model.ms3d");
IAnimatedMeshSceneNode* node = sceneManager->addAnimatedMeshSceneNode(mesh);
Code: Select all
IAnimatedMesh* mesh = sceneManager->getMesh("model.ms3d");
ISceneNode* node = sceneManager->addMeshSceneNode( mesh->getMesh(0) );
This way it also works - until I want to close my program/shutdown the engine. When I click on the close button of my window, the destructor calls "m_pDevice->drop();" to shutdown Irrlicht. But then (and only with the "addMeshSceneNode", not with the "addAnimatedMeshSceneNode"), Visual Studio (I use version 2003) stops and displays a message with an "Unhandled Exception at.... " (no more information). The compiler shows the file "iunknown.h" with this code:
Code: Select all
bool drop()
{
#if defined(_DEBUG) && defined(_MSC_VER)
if (ReferenceCounter <= 0)
_asm int 3; // someone is doing bad reference counting.
#endif
--ReferenceCounter;
if (!ReferenceCounter)
{
delete this; // ***
return true;
}
return false;
}
So the error must have to do with a reference counter, maybe something where the engine needs a ->drop() or something (when I don't destroy the engine/no call to device->drop()) the error doesn't appear)
Please, can anyone help? I just don't know what I'm doing wrong. Is my "addMeshSceneNode"-codeline wrong? Or must I use ->drop() on any object?
Thanks a lot for your help!