简体   繁体   English

Ogre中带有sdkTrays的未处理异常小部件

[英]unhandled exception widget with sdkTrays in Ogre

I have some serious issues with sdkTrays in Ogre. 我在Ogre中的sdkTrays有一些严重的问题。

I have my OgreKinectGame that inherits from BaseApplication. 我有从BaseApplication继承的OgreKinectGame。 BaseApplication is creating logo etc. using sdkTrayManager. BaseApplication正在使用sdkTrayManager创建徽标等。 I thought this mTrayMgr was inherited and can be used in my application as well. 我认为此mTrayMgr是继承的,也可以在我的应用程序中使用。

I am trying to setup widgets for a HUD, but I'm getting unhandled exception errors. 我正在尝试为HUD设置窗口小部件,但出现了未处理的异常错误。

My setupWidgets() function looks like this. 我的setupWidgets()函数如下所示。

void OgreKinectGame::setupWidgets()

{ {

if(!mTrayMgr)
    mTrayMgr = new SdkTrayManager("InterfaceName", mWindow, mMouse);

    //mTrayMgr->destroyAllWidgets(); this caused exceptions as well
    // create check boxes to toggle the visibility of our particle systems
    const int WIDTH_UI = 160;
    // main menu
    mTrayMgr->createLabel(TL_CENTER, "mMainMenuLabel", "Main Menu", WIDTH_UI);
    mTrayMgr->createButton(TL_CENTER, "mOptionButton", "Option");
    mTrayMgr->createButton(TL_CENTER, "mCreditButton", "About");
    mTrayMgr->createButton(TL_CENTER, "mQuitButton", "Quit");

    mTrayMgr->showAll();

} } 未处理的异常

First, where did you initialize your setupWidgets()? 首先,您在哪里初始化setupWidgets()? , on BaseApplication class, they have setup(), you can create a virtual of this setup() to your main class and then initialize your setupWiget() there, eg, ,在BaseApplication类上,它们具有setup(),您可以在主类中创建此setup()的虚拟对象,然后在其中初始化setupWiget(),例如,

bool OgreKinectGame::setup(void)
{
   if (!BaseApplication::setup()) {
    return false;
   }
   // Load fonts for tray captions
   FontManager::getSingleton().getByName("SdkTrays/Caption")->load();
   setupWidgets();//initialize here for your setupWidget()
} 

second, I think your setupWidget() should be like this, 其次,我认为您的setupWidget()应该像这样,

void OgreKinectGame::setupWidgets()
{
    const int WIDTH_UI = 160;
    // main menu
    mTrayMgr->createLabel(TL_CENTER, "mMainMenuLabel", "Main Menu", WIDTH_UI);
    mTrayMgr->createButton(TL_CENTER, "mOptionButton", "Option");
    mTrayMgr->createButton(TL_CENTER, "mCreditButton", "About");
    mTrayMgr->createButton(TL_CENTER, "mQuitButton", "Quit");
}

Can you try this solution and back again if still get crash? 您是否可以尝试此解决方案,如果仍然崩溃,可以再次返回?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM