Multiple rendering windows, not all visible? Topic is solved

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


jwwalker
Goblin
Posts: 248
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 18

Multiple rendering windows, not all visible?

Post by jwwalker »

In the sample programs, rendering is done by Demo::GraphicsSystem::update which basically says

Code: Select all

if (mRenderWindow->isVisible()) mRoot->renderOneFrame();
What if I have multiple windows, and maybe some are visible and some are not? Do I go ahead and call renderOneFrame and maybe let it waste time rendering invisible things? I assume I should have only one Ogre::Root object in my application.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5436
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1343

Re: Multiple rendering windows, not all visible?

Post by dark_sylinc »

Hi!

That's correct, if at least one of them is visible then you have to call renderOneFrame.

Compositor setups can be simple to arbitrarily complex. You can individually disable workspaces to avoid rendering to specific windows (assuming you have 1 workspace per render window, like I said... your setup can be arbitrarily complex);

Code: Select all

workspaceForThatWindow->setEnabled( mRenderWindow->isVisible() );
This will save you some GPU & CPU work.

Cheers
Matias
jwwalker
Goblin
Posts: 248
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 18

Re: Multiple rendering windows, not all visible?

Post by jwwalker »

Thanks, that sounds fine, except it's not obvious to me how to associate a window and a workspace. I don't see any methods on Window where you specify a CompositorWorkspace or anything like that.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5436
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1343

Re: Multiple rendering windows, not all visible?

Post by dark_sylinc »

Hi!

When you call addWorkspace there is a parameter to specify one or multiple TextureGpu as "external" targets.

Later inside the compositor your workspace and nodes will define what they do with these external targets (usually its because either you want to render to them; or because its a temporary target you want to share with all workspaces to save memory)

e.g.

Code: Select all

compositorManager->addWorkspace( mSceneManager, mRenderWindow->getTexture(), mCamera, workspaceName, true )
As for "how it's associated" depends on what you do. You could for example create a workspace definition that renders to multiple render windows at once (IMHO that would be crazy but that's up to you). Multiple workspaces may also draw to the same Render Window if you want (I never tried that though, I suspect it could have issues in Vulkan?) e.g.

Code: Select all

CompositorChannelVec externalTagets;
externalTagets.push_back( window0->getTexture() );
externalTagets.push_back( window1->getTexture() );
externalTagets.push_back( window2->getTexture() );
compositorManager->addWorkspace( mSceneManager, externalTagets, mCamera, workspaceName, true )
or you could do 1 workspace per window.

So it's not so much that as that you tell "a Render Window to have a CompositorWorkspace associated to it" but rather you grabbed a CompositorWorkspace and told it to output into the TextureGpu associated with that window.

For more info see the Compositor section.