Ogre single window 2 viewports 2 guicontext

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

limesX
Just popping in
Just popping in
Posts: 3
Joined: Sat Mar 22, 2014 15:57

Ogre single window 2 viewports 2 guicontext

Postby limesX » Sun Mar 23, 2014 07:37

Hi. I am using CEGUI 0.8.3 and Ogre 1.8.1
I initiate Ogre on single window with 2 viewports. I want to have 2 GUIContext (1 for each viewport).
Viewports split window in two parts by height (horizontal split). Is this possible?
This what I have done so far, but I cant get any CEGUI window shown on second viewport.
Here is the code:

Code: Select all

CODE:
   CEGUI::OgreRenderer* mRenderer1 = &CEGUI::OgreRenderer::create();
   mRenderer1->setDefaultRootRenderTarget(*mWindow);
   CEGUI::Rectf rect = mRenderer1->getDefaultRenderTarget().getArea();
   float width = rect.d_max.d_x; float height = rect.d_max.d_y;
   mRenderer1->getDefaultRenderTarget().setArea(CEGUI::Rectf(0, 0, width, height/2.0));
   CEGUI::System::create(*mRenderer1);
   CEGUI::GUIContext* guiContext1 = new CEGUI::GUIContext( mRenderer1->getDefaultRenderTarget() );
   CEGUI::Window* myRoot1 = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "myRoot1");
   guiContext1->setRootWindow( myRoot1);

   CEGUI::OgreRenderer* mRenderer2 = &CEGUI::OgreRenderer::create();
   mRenderer2->setDefaultRootRenderTarget(*mWindow);
   mRenderer2->getDefaultRenderTarget().setArea(CEGUI::Rectf(0, height/2.0, width, height));
   CEGUI::GUIContext* guiContext1 guiContext2 = new CEGUI::GUIContext( mRenderer2->getDefaultRenderTarget() );
   CEGUI::Window* myRoot2 = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "myRoot2");
   guiContext2->setRootWindow( myRoot2);


Now follows some standar initializaion and later in frameRenderingQueued:

Code: Select all

CODE:
   CEGUI::System::getSingleton().injectTimePulse(evt.timeSinceLastFrame);
   CEGUI::System::getSingleton().renderAllGUIContexts();

   guiContext1->injectTimePulse(evt.timeSinceLastFrame);
   guiContext2->injectTimePulse(evt.timeSinceLastFrame);

   mRenderer1->beginRendering();
   guiContext1->draw();
   mRenderer1->endRendering();


   mRenderer2->beginRendering();
   guiContext2->draw();
   mRenderer2->endRendering();


I added single CEGUI window to each rooot window of each guicontext but only first one is showing.
Any help?

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Ogre single window 2 viewports 2 guicontext

Postby Ident » Sun Mar 23, 2014 17:32

So far this sounds like an Ogre issue. What you described can be done with CEGUI. The way I would do this is to render the GUI to a texture and then render this texture using a Ogre ManualObject placed anywhere you want.
Maybe this helps you, I recently wrote this: http://cegui.org.uk/wiki/Rendering_to_t ... 9_in_CEGUI

You probably can also render it directly on the screen, but I do not know why. You would have to look inside the Ogre Renderer to see how the viewport etc is set up because none of the current developers has written the Ogre Renderer, so I doubt anyone knows a quick answer. If you have CEGUI-related issues ask and we can definitely help you. Otherwise I suggest to do it with RTT.

BTW:

Code: Select all

  CEGUI::System::getSingleton().renderAllGUIContexts();

You do not need this if you draw the GUIContexts manually.
CrazyEddie: "I don't like GUIs"

limesX
Just popping in
Just popping in
Posts: 3
Joined: Sat Mar 22, 2014 15:57

Re: Ogre single window 2 viewports 2 guicontext

Postby limesX » Sun Mar 23, 2014 19:41

thank you for help but I have one more question before even trying what you described.
if I render everything to texture, will I be able to interact with gui (button clicks, opening list boxes etc.....)?

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Ogre single window 2 viewports 2 guicontext

Postby Ident » Sun Mar 23, 2014 19:44

If you send the right coordinates for your mouse and inject all key and mouse button inputs (as usual) to both then yes - why not? You just need to always inject the inputs in a way that they match what you expect. CEGUI does not know about where the inputs come from and it doesnt care, it just cares about what it receives. You could simulate any kind of inputs if you wanted to. So basically in your case the only tricky part is sending the right (converted) mouse coordinates. If you know the application window coordinates and the coordinates of where you are rendering your GUI in your application, this should be really easy. You can figure the calculations our on your own. Also remember to render your ManualObject in front of everything else.
CrazyEddie: "I don't like GUIs"

User avatar
mmixLinus
Quite a regular
Quite a regular
Posts: 71
Joined: Fri May 20, 2011 08:46
Location: Lund, Sweden
Contact:

Re: Ogre single window 2 viewports 2 guicontext

Postby mmixLinus » Sun Mar 23, 2014 21:47

Hi limesX

I render CEGUI to a default GUIContext with a root window that covers my entire Ogre scene. In that Ogre scene, I have an object with a specific texture into which I render a second CEGUI GUIContext (containing other buttons etc.) (It took a bit of mindbending for me to understand how to do this, but thanks to Ident, who authored the RTT page, I found it wasn't that hard after all.) Needless to say, the buttons in this second context, can be viewed from any angle, and may be slightly warped due to the underlying mesh that they are rendered upon. I use the Raycasting to the polygon level code to inject appropriately warped mouse coordinates :hammer: to the 2nd GUIContext. So I can manipulate these widgets despite their being viewed from an angle. Any angle actually. It works pretty well, but that could be because the underlying mesh is well-behaved (it is rectangular, and only slightly bent)

Just put the pieces together :wink:
.mmixLinus
MMiX.Me 3D Music Player
Galaxy Navigator 3D - 2 million stars (ESA's Gaia satellite)
(YouTube|Facebook)

limesX
Just popping in
Just popping in
Posts: 3
Joined: Sat Mar 22, 2014 15:57

Re: Ogre single window 2 viewports 2 guicontext

Postby limesX » Tue Mar 25, 2014 07:48

ok. will try with your approach then. thanx


Return to “Help”

Who is online

Users browsing this forum: No registered users and 28 guests