OGRE 引擎可以渲染到任何窗口中吗?

发布于 2024-12-09 14:24:56 字数 348 浏览 1 评论 0原文

我正在制作一个小型插件类图形引擎接口,它在内部使用 OGRE。这个想法是,在 Windows 或 Linux 中创建程序的人将能够使用我的插件来完成他们需要做的任何图形渲染。

事实上,已经有一个使用 GDI 和 GDI 的 Windows 应用程序。 D3D调用进行绘图,我需要对其进行修改,以便它可以使用OGRE进行绘图。

让我困惑的是,该应用程序是用 VC++ 编写的,因此具有 Windows 风格的菜单和绘图客户区。但是由于OGRE创建了自己的渲染窗口,我是否可以将应用程序窗口的客户区域的句柄发送给OGRE,并且OGRE会在窗口的客户区域中进行所有绘制?

我是 Windows 编程新手,并且时间有限,所以不得不在这里提问。

I'm making a small plugin-kind-of graphics engine interface which uses OGRE internally. The idea is that a person creating a program in Windows or Linux, would be able to use my plugin for doing any graphics rendering they need to do.

In-fact there's already a Windows app using GDI & D3D calls to do drawing, which I need to modify so that it can use OGRE to do the drawing.

What puzzles me is that the app is programmed in VC++ and hence has Windows-style menus and client area for drawing. But since OGRE creates its own window for rendering, will it be possible for me to send a handle of the client area of the app's window to OGRE and will OGRE do all the drawing in the client area of the window?

I'm new to Windows programming and under a bit of a time constraint, so had to ask here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

记忆之渊 2024-12-16 14:24:56

也许这可以帮助:

Ogre::String winHandle;
  #ifdef WIN32
  // Windows code
  winHandle += Ogre::StringConverter::toString((unsigned long)(this->parentWidget()->winId()));
  #else
  // Unix code
  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)(this->parentWidget()->winId()));
  #endif

  Ogre::NameValuePairList params;
  params["parentWindowHandle"] = winHandle;

  mOgreWindow = mOgreRoot->createRenderWindow( "QOgreWidget_RenderWindow",
                           this->width(),
                           this->height(),
                           false,
                           ¶ms );

QX11Info 是 Qt 类,用于获取句柄。
句柄作为名称:“parentWindowHandle”插入到 Ogre::NameValuePairList 值:你的句柄和 10 个作为参数发送给 OgreRoot::createRenderWindow()。我用 Qt 尝试了这段代码,它成功了。如果它不起作用,请尝试使用 externalWindowHandle 作为参数名称。

来源:http://www.ogre3d.org/tikiwiki/QtOgre

maybe this can help:

Ogre::String winHandle;
  #ifdef WIN32
  // Windows code
  winHandle += Ogre::StringConverter::toString((unsigned long)(this->parentWidget()->winId()));
  #else
  // Unix code
  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)(this->parentWidget()->winId()));
  #endif

  Ogre::NameValuePairList params;
  params["parentWindowHandle"] = winHandle;

  mOgreWindow = mOgreRoot->createRenderWindow( "QOgreWidget_RenderWindow",
                           this->width(),
                           this->height(),
                           false,
                           ¶ms );

QX11Info is Qt class, used to get handle.
Handle is inserted to Ogre::NameValuePairList as name:"parentWindowHandle" value: your handle and ten sent as argument to OgreRoot::createRenderWindow(). I tried this code with Qt and it worked. If it wont work try to use externalWindowHandle as parameter name.

source: http://www.ogre3d.org/tikiwiki/QtOgre

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文