Ogre Overlay on top of CEGUI

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

blablub
Not too shy to talk
Not too shy to talk
Posts: 28
Joined: Tue Mar 01, 2011 11:56

Ogre Overlay on top of CEGUI

Postby blablub » Mon Jul 04, 2011 14:07

Hi,

I have CEGUI 0.7.5 and are bootstrapping it to the OgreRenderer.

But all the CEGUI elements are on top of my Ogre overlays. I want it the other way round (-> Ogre Overlay on top of CEGUI).

I found a solution with setRenderTargetQueue(), but this function doesn't seem to exist in 0.7.5.

How can I change this behavior?

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: Ogre Overlay on top of CEGUI

Postby Kulik » Mon Jul 04, 2011 16:06

I don't have the exact details of how to do this but I recall someone asking for this, so this is already in the forum somewhere.

General idea is that you have to disable the automatic CEGUI rendering and render when you want.

User avatar
Jabberwocky
Quite a regular
Quite a regular
Posts: 86
Joined: Wed Oct 31, 2007 18:16
Location: Canada
Contact:

Re: Ogre Overlay on top of CEGUI

Postby Jabberwocky » Tue Jul 05, 2011 21:55

Yeah, you need to call:

Code: Select all

CEGUI::OgreRenderer::setFrameControlExecutionEnabled( false );

to tell CEGUI not to render, so you can explicitly tell it when to render, after the overlays in your case.

My code looks something like this (chopped out a bunch of stuff for simplicity, not-tested):

Code: Select all

class UISystem: public Ogre::RenderQueueListener
{
public:
   void Init( Ogre::SceneManager* pSceneMgr );
   // We can specify a RenderQueue to render the UI on (actually before or after).
   void SetRenderQueue( Ogre::RenderQueueGroupID i_nRenderQueue, bool i_bPostQueue );
   void renderQueueStarted(Ogre::uint8 id, const Ogre::String& invocation, bool& skipThisQueue);
   void renderQueueEnded(Ogre::uint8 id, const Ogre::String& invocation, bool& repeatThisQueue);

private:
   // When we draw the UI.
   Ogre::RenderQueueGroupID m_nRenderQueue;
   // Whether to draw CEGUI immediately before or after m_nRenderQueue
   bool m_bPostQueue;
};


Code: Select all

void UISystem::Init( Ogre::SceneManager* i_pSceneMgr )
{
   // -- a bunch of other CEGUI initialization code omitted here for brevity ---

   // tell CEGUI that we want to handle the calls to CEGUI::System::renderGUI()
   GetCEGUIOgreRenderer()->setFrameControlExecutionEnabled( false );

   // Register a RenderQueueListener so we have a hook to call CEGUI::System::renderGUI()
   // Be careful not to call this function more than once, or you will render your GUi multiple times per tick
   i_pSceneMgr->addRenderQueueListener( this );
}

void UISystem::SetRenderQueue( Ogre::RenderQueueGroupID i_nRenderQueue, bool i_bPostQueue )
{
   m_nRenderQueue = i_nRenderQueue;
   m_bPostQueue = i_bPostQueue;
}

void UISystem::renderQueueStarted(Ogre::uint8 id, const Ogre::String& invocation, bool& skipThisQueue)
{
   // make sure you check the invocation string, or you can end up rendering the GUI multiple times
   // per frame due to shadow cameras.
   if ( !m_bPostQueue && m_nRenderQueue == id && invocation == "" )
   {
      CEGUI::System::getSingleton().renderGUI();
   }
}

void UISystem::renderQueueEnded(Ogre::uint8 id, const Ogre::String& invocation, bool& repeatThisQueue)
{
   if ( m_bPostQueue && m_nRenderQueue == id && invocation == "" )
   {
      CEGUI::System::getSingleton().renderGUI();
   }
}


If you want CEGUI to render after overlays, try:

Code: Select all

UISystem->SetRenderQueue( RENDER_QUEUE_OVERLAY, true );
The Salvation Prophecy
Space Combat. Planet Exploration. Strategic Domination.


Return to “Help”

Who is online

Users browsing this forum: Baidu [Spider] and 29 guests