Try to init a MyGUI, but get an Runtime error

Nekomaru

28-10-2010 17:35:19

Hello there. I have a problem while init MyGUI
Code:



INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
{

//Root, SceneManager and RenderWindow
//=========================================//
Ogre::Root *mRoot;
Ogre::SceneManager *mScnMgr;
Ogre::RenderWindow *mRndWindow;

mRoot = OGRE_NEW Ogre::Root(pluginsCfg, ogreCfg);
mScnMgr = mRoot->createSceneManager(Ogre::ST_GENERIC);

mRoot->showConfigDialog();
mRoot->saveConfig();

mRoot->initialise(true, "Game Framework");
mRndWindow = mRoot->getAutoCreatedWindow();
//=========================================//

//Camera, Viewport
//=========================================//
Ogre::Viewport *mVp;
Ogre::Camera *mCamera;

mCamera = mScnMgr->createCamera("MainCamera");
mCamera->setPosition(0, 0, -50);

mCamera->lookAt(Ogre::Vector3(0,0,0));
mCamera->setNearClipDistance(5);
mCamera->setFarClipDistance(1000);

mVp = mRndWindow->addViewport(mCamera);
mVp->setBackgroundColour(Ogre::ColourValue(0.45,0.3,0.58));

mCamera->setAspectRatio(
Ogre::Real(mVp->getActualWidth()) / Ogre::Real(mVp->getActualHeight()));
//=========================================//

//MyGUI
//=========================================//
MyGUI::Gui* mGUI;
MyGUI::OgrePlatform* mPlatform;

mPlatform = new MyGUI::OgrePlatform();
mPlatform->initialise(mRndWindow, mScnMgr); // mWindow is Ogre::RenderWindow*, mSceneManager is Ogre::SceneManager*
mGUI = new MyGUI::Gui();
mGUI->initialise();

//RenderLoop
//=========================================//
while(true)
{
// Pump window messages for nice behaviour
Ogre::WindowEventUtilities::messagePump();

if(mRndWindow->isClosed())
{
return 0;
}

// Render a frame
if(!mRoot->renderOneFrame()) return 0;
}
//=========================================//

return 0;
}


I run the application and get a runtime error. What should i do?

Altren

29-10-2010 00:46:11

You should look into MyGUI.log and Ogre.log. If they have no errors, then you should run your application with debugger to see where it crashes.

Nekomaru

29-10-2010 12:50:22

I've already done it.

mPlatform->initialise(mRndWindow, mScnMgr); // here
mGUI->initialise(); // and here

Read Topic please.

Altren

29-10-2010 14:04:10

And what about logs?

Nekomaru

29-10-2010 15:22:18

I can't init a Gui and OgrePlatform objects. So, log file is not ever created.

my.name

31-10-2010 15:46:07

if you using VS, start program in debug mode - F5 and show stack trace.