我正在尝试使用下面给出的代码在Ot中嵌入Ogre: https://github.com/gklingler/QOgreWidget
它在我的系统上正常运行没有任何问题但是当我尝试在我的Qt应用程序中添加相同内容时,我收到以下错误:
SceneManagerFactory for type 'PCZSceneManager' registered.
MovableObjectFactory for type 'PCZLight' registered.
MovableObjectFactory for type 'Portal' registered.
MovableObjectFactory for type 'AntiPortal' registered.
PCZone Factory Type 'ZoneType_Octree' registered
SceneManagerFactory for type 'OctreeSceneManager' registered.
app: ../app/ogre/ogrebasewidget.cpp:45: OgreBaseWidget::OgreBaseWidget(Ogre::Root*, OgreEventHandler*, QWidget*): Assertion `ogreWinId' failed.
The program has unexpectedly finished.
错误指向此代码段:
Ogre::String winHandle;
winHandle = Ogre::StringConverter::toString((unsigned long) (QX11Info::display()));
winHandle += " : ";
winHandle = Ogre::StringConverter::toString((unsigned long) (QX11Info::appScreen()));
winHandle += " : ";
winHandle = Ogre::StringConverter::toString((unsigned long) (winId()));
Ogre::NameValuePairList params;
params["parentWindowHandle"] = winHandle;
params["FSAA"] = Ogre::String("8");
int w = width();
int h = height();
mOgreRenderWindow = mOgreRoot->createRenderWindow("OgreWidget_RenderWindow",
qMax(w, 640),
qMax(h, 480),
false, ¶ms);
mOgreRenderWindow->setActive(true);
mOgreRenderWindow->setVisible(true);
WId ogreWinId = 0x0;
mOgreRenderWindow->getCustomAttribute("WINDOW", &ogreWinId);
assert(ogreWinId);
QWidget::create(ogreWinId);
setAttribute(Qt::WA_OpaquePaintEvent);
我在标题中加入了<cassert>
。帮我解决这个问题。 :(
答案 0 :(得分:0)
我找到了它给出此错误的原因。 我安装了旧版本(1.7.4)的Ogre以及更新的1.9版本。
所以我从我的系统中清除了这个旧版本,瞧它就像一个魅力。