开发者

Can an OGRE engine render into any window?

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 th开发者_如何学Pythone 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.


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,
                           &params );

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜