Code: Select all
struct world
{
irr::IrrlichtDevice* device;
irr::gui::IGUIEnvironment* guienv;
ISceneManager* smgr;
IVideoDriver* driver;
irr::newton::IWorld* p_world;
irr::newton::IBody* fairy_body;
irr::scene::CCameraRPGSceneNode* mycam;
irr::scene::ITriangleSelector* selector;
irr::scene::ISceneNode* selectedSceneNode;
irr::scene::ISceneNode* lastSelectedSceneNode;
irr::scene::IAnimatedMeshSceneNode* fairy;
IGUIListBox* console;
irr::gui::IGUIButton* button_quit;
irr::gui::IGUIButton* button_tutorial;
irr::gui::IGUIButton* button_takephoto;
irr::gui::IGUIButton* button_editor;
irr::gui::IGUIButton* button_normalmode;
irr::gui::IGUIButton* button_newobject;
irr::gui::IGUIButton* button_deleteobject;
irr::gui::IGUIButton* button_texture;
irr::scene::IAnimatedMeshSceneNode* mymodel;
int mouse_over_gui;
int file_dialog_open;
int object_count;
int editor_active;
int file_open_type;
int object_selected;
ISoundEngine* mysoundengine;
VxCompass* pgCompass;
};
Code: Select all
void init_world(world myworld)
{
myworld.device = createDevice(EDT_DIRECT3D9, dimension2d<s32>(400, 300), 32, false, false, false, 0);
myworld.device->setWindowCaption(L"blabla");
//...and more stuf...(load, world, sound, physics...)
}
void run_world(world myworld)
{
while(myworld.device->run())
{
//update physics
myworld.p_world->update();
myworld.driver->beginScene(true, true, SColor (0,200,200,200));
myworld.smgr->drawAll();
myworld.guienv->drawAll();
myworld.driver->endScene();
}
}
void destroy_world(world myworld)
{
myworld.mysoundengine->stopAllSounds(); // delete sound engine
myworld.mysoundengine->drop(); // delete sound engine
myworld.device->drop();
}
Code: Select all
world theworld;
init_world(theworld);
run_world(theworld);
destroy_world(theworld);
while(myworld.device->run())
and says:
Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'c:\bla.exe'.
Additional Information: The runtime has encountered a fatal error. The address of the error was at 0x79ef572b, on thread 0xcc4. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
Whats wrong?