English 中文(简体)
4. 将OGRE 1.7.3纳入Qt 4.8
原标题:Integrating OGRE 1.7.3 in Qt 4.8

我试图将ogre3d widget植入乌班图的qt widget,但我们看到黑色屏幕。

当我们:Root:RenderWindow没有父母的植被(作为主要窗口)时,一切都可行。 但是,当我们创造活力时:Root:RenderWindow作为其他主要窗口的儿童窗口时,我们会遇到无法工作的问题。

该守则是:

cpp:

标题:

问题回答

我有这个问题,我需要用下文所示的<代码>XSync方法。 这是<代码>的一部分。 OgreWidget: initialize methods, where OgreWidget/code> subclasses QWidget initialize is calls as part of Construction of OgreWidget,在m_OgreRoot之后,分配并设定了成因系统。

setAttribute(Qt::WA_PaintOnScreen, true);
setAttribute(Qt::WA_NoSystemBackground, true);

setFocusPolicy(Qt::StrongFocus);

Ogre::String winHandle;
QX11Info info = x11Info();
winHandle = Ogre::StringConverter::toString((unsigned long)(info.display()));
winHandle += ":";
winHandle += Ogre::StringConverter::toString((unsigned int)(info.screen()));
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();
// Need to call XSync or the window handles will be invalid.
XSync(info.display(), False);
m_OgreWindow =
      m_OgreRoot->createRenderWindow("OgreWidget_RenderWindow",
                                     qMax(w, 640), qMax(h, 480), false, &params);

此处为经修改的编号5.1.0的同一代码:QX11Info被移至Qt 5.0.x,然后添加到Qt 5.1.0的“Exras”部分。 新的<代码>QX11Info类别只有固定方法。

#include <QtX11Extras/QX11Info>
...
setAttribute(Qt::WA_PaintOnScreen, true);
setAttribute(Qt::WA_NoSystemBackground, true);

setFocusPolicy(Qt::StrongFocus);

Ogre::String winHandle;
winHandle = Ogre::StringConverter::toString((unsigned long)(QX11Info::display()));
winHandle += ":";
winHandle += Ogre::StringConverter::toString((unsigned int)(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();
// Need to call XSync or the window handles will be invalid.
XSync(QX11Info::display(), False);
m_OgreWindow =
      m_OgreRoot->createRenderWindow("OgreWidget_RenderWindow",
                                     qMax(w, 640), qMax(h, 480), false, &params);




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?