3

I'm trying to create a windowless Ogre application, but it seems that the method RenderWindow::setVisible(false) is completely ignored by the application. Is there a way to accomplish that?

Thank you
Tommaso

tunnuz
  • 23,338
  • 31
  • 90
  • 128
  • Having never used ogre I would assume that `setVisible(true)` would mean **show** the window? – Nifle Mar 07 '10 at 17:46

2 Answers2

8

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.

svenstaro
  • 1,783
  • 2
  • 21
  • 31
  • So it's supposed to have a working RenderTexture without a RenderWindow? I've a weird problem with RenderTexture: [RenderTexture bigger than RenderWindow](http://stackoverflow.com/questions/7930306/ogre-3d-rendertexture-bigger-than-renderwindow) – Alessandro Pezzato Nov 10 '11 at 14:42
  • 1
    But RenderTexture is an abstract class in 1.9? – paulm Feb 08 '15 at 17:21
0

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
}
Azerty45
  • 1
  • 3