开发者

How to get a windowless application in Ogre?

I'm trying to create a windowless Ogre application, but it seems that the method RenderWindow::setVisible(false) is completely igno开发者_运维百科red by the application. Is there a way to accomplish that?

Thank you

Tommaso


You should not be using RenderWindow but RenderTexture if you don't want to open a window. It works almost exactly the same as RenderWindow because it is derived from RenderTarget as well. You should have almost no trouble just switching them around with your current parameters except for changing the constructor.

Please update your question with some concrete code if you do run into trouble with the switch.


As far as I know you have to create a window even if you just want create a windowless app. It is not possible to initialize Ogre without creating a RenderWindow (window = m_root->initialise(true, "App")) With Ogre 1.8 you can hide the window by calling window->setHidden(true) Thanks to this method you can bypass the problem and make a "windowless" app.

As Svenstaro said, you can redirect the rendering into a RenderTexture. I use the code below to render my frames into a texture :

m_window = m_root->initialise(true, "App");
m_window->setHidden(true);
Ogre::WindowEventUtilities::messagePump(); // Force the window to be hidden (necessary under Ubuntu for my case)

m_camera = m_sceneMgr->createCamera("Cam");

Ogre::TexturePtr rtt_texture = Ogre::TextureManager::getSingleton().createManual("RttTex",
                Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                Ogre::TEX_TYPE_2D, 640, 480, 0,
                Ogre::PF_R8G8B8,
                Ogre::TU_RENDERTARGET);

Ogre::RenderTexture* m_tex = rtt_texture->getBuffer()->getRenderTarget();
Ogre::Viewport* vp = m_tex->addViewport(m_camera);
vp->setClearEveryFrame(true);
vp->setBackgroundColour(Ogre::ColourValue::Black);
vp->setOverlaysEnabled(false);
m_camera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));

In the RenderLoop :

while(1)
{
  m_root->renderOneFrame();
  m_tex->update();

  // Other stuffs
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜