[Solved] Ogre Dual monitor application

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

kiske1
Just popping in
Just popping in
Posts: 17
Joined: Fri May 20, 2016 11:53

[Solved] Ogre Dual monitor application

Postby kiske1 » Wed Jul 06, 2016 16:17

Hello,

I'm trying to use CEGUI in my Ogre application, that works with 2 indipendent windows each of them on different monitor.

I came across these 2 threads:
http://cegui.org.uk/forum/viewtopic.php?f=10&t=6971
and
http://cegui.org/forum/viewtopic.php?f=10&t=6831&sid=292d88310f7b2d97b372d3125e8bfd5f

As far as I can understand, they're based on different approaches, while the first one basically creates 2 ogrerenderer, the second one only creates a new context for the new window. Please tell me if I understood it correctly and what is the best approach.

I've managed to get both approaches to work correctly, but only if the windows are created in the same monitor, and not moved from there. As soon as I move the window to another monitor I get an INVALID_CALL exception thrown by D3D upon "drawprimitive" in the Ogre D3D9 rendersystem. Any clue where to look at?

Thanks!

PS.
The project uses Ogre 1.9 with D3D9 Rendersystem and CEGUI 0.8.7

PS2.
This is crossposted on Ogre forums, here: http://www.ogre3d.org/forums/viewtopic.php?f=2&t=88638

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Dual monitor application

Postby YaronCT » Thu Jul 07, 2016 20:02

@kiske1: That's an interesting problem, I've never dealt with multiple monitors b4. I'll look into it, but it might take some time.

kiske1
Just popping in
Just popping in
Posts: 17
Joined: Fri May 20, 2016 11:53

Re: Dual monitor application

Postby kiske1 » Fri Jul 08, 2016 07:15

@YaronCT

I've just managed to find out what the problem was. Basically the problem was that when the ogre renderwindows are created a different d3ddevice is created for every monitor used. In the CEGUI::OgreRenderer, when beginRendering() (and endRendering) is called it always activates the renderTarget relative to the default (eg first) GUIContext, and this causes the default device to be always used. In the CEGUI source in fact there is a FIXME comment on this line.

What I've done to overcome the problem was to create a new beginRendering() (and endRendering() ) overload wich takes a GUIContext as a parameter, changing

Code: Select all

//FIXME: ???
    System::getSingleton().getDefaultGUIContext().getRenderTarget().activate();

to

Code: Select all

Context->getRenderTarget().activate();


After recompiling CEGUIOgreRenderer, in my app I disabled automated rendering and FrameControlExecution with that:

Code: Select all

   mRenderer->setFrameControlExecutionEnabled(false);
   mRenderer->setRenderingEnabled(false);   


and then attached an Ogre::RenderTargetListener to each of the windows, and in the postRenderTargetUpdate() I've made the actual draw call for each. Eg. for the first one:

Code: Select all

      
      mGUIManager->getRenderer()->beginRendering(mGUIManager->getContext1());
      mGUIManager->getContext1()->draw();
      mGUIManager->getRenderer()->endRendering(mGUIManager->getContext1());


and for the second one

Code: Select all

      
      mGUIManager->getRenderer()->beginRendering(mGUIManager->getContext2());
      mGUIManager->getContext2()->draw();
      mGUIManager->getRenderer()->endRendering(mGUIManager->getContext2());


I'm pretty sure that it isn't the best way, but it actually does the job... :D

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: [Solved] Ogre Dual monitor application

Postby YaronCT » Sat Jul 16, 2016 15:01

@kiske1: Gotta love those "FIXME"-s..

I've submitted a fix to cegui branch "v0-8". Can u plz test it?


Return to “Help”

Who is online

Users browsing this forum: Google [Bot] and 16 guests