English 中文(简体)
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 ignored 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
}




相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签