[Solved] CEGUI initialisation causes flickering (ogre 2.0)

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

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

Re: CEGUI initialisation causes flickering (ogre 2.0)

Postby Ident » Mon Aug 03, 2015 18:35

Did you look at the PR i linked? It states 2.0 support for v0-8
CrazyEddie: "I don't like GUIs"

jjonj
Not too shy to talk
Not too shy to talk
Posts: 28
Joined: Fri Mar 21, 2014 22:11

Re: CEGUI initialisation causes flickering (ogre 2.0)

Postby jjonj » Wed Aug 05, 2015 01:38

EDIT: Hadn't seen your reply since it was on page 2. The pullrequest states support for ogre 2.1 which is fairly different from ogre 2.0 so that might be why it doesn't work on 2.0.
If i compare the Renderer.cpp files for default and 0.8 branches the default one does a lot of stuff with compositors while the 0.8 branch does little more than include the headers and ogre 2.0 relies heavily on compositors, don't know about 2.1.


I managed to make a workaround for the problem!

The issue occurred because there we're two "workspaces" in the ogre compositor manager, ogres and CEGUIs, each rendering loop OgreRoot.cpp called _swapAllFinalTargets() which calls OgreCompositorManager2.cpp's _swapAllFinalTargets() which for each workspace calls _swapFinalTarget() which on windows simply calls a native windows frame buffer swap. Since there we're two workspaces, that native function was called twice in a row, effectively having the second swap undo the first and resulting in an empty buffer being displayed.

I think the flickering occurred (as opposed to simply being always black) due to the display driver sometimes fetching the buffer in between the two calls, but I'm not entirely sure.

Now to me it seems really strange that you would want to swap the native buffers for each workspace and hence get an empty buffer when you have an even number of workspaces, but I don't know much about graphics programming let alone the internals of ogre so maybe something was supposed to work differently, don't know but I'll bring this up on the ogre forums.

My workaround was to, when iterating all the workspaces, always return from the function after having called the swap function for the first workspace and ignore the rest.
I added the return line in this function in OgreCompositorManager2.cpp

Code: Select all

   void CompositorManager2::_swapAllFinalTargets(void)
    {
        WorkspaceVec::const_iterator itor = mWorkspaces.begin();
        WorkspaceVec::const_iterator end  = mWorkspaces.end();

        while( itor != end )
        {
            CompositorWorkspace *workspace = (*itor);
            if( workspace->getEnabled() && workspace->isValid() )
                workspace->_swapFinalTarget();
            return;
            ++itor;
        }
    }


That swap function calls this function:

Code: Select all

void CompositorWorkspace::_swapFinalTarget(void)
    {
        if( mRenderWindow.target )
            mRenderWindow.target->swapBuffers();
    }

the swap there calls this function:

Code: Select all

void Win32Window::swapBuffers()
    {
      if (!mIsExternalGLControl) {
        SwapBuffers(mHDC);
      }
    }
   

and that SwapBuffers is a native windows function.

This looks like an ogre issue to me, so do you want me to do anything about that ticket I created? Or just leave it be until we get some feedback from the ogre forums?

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

Re: CEGUI initialisation causes flickering (ogre 2.0)

Postby Ident » Wed Aug 05, 2015 10:39

Leave it until you get feedback from Ogre. Is there a related ticket at Ogre or a thread? Then reference this in the CEGUI ticket
CrazyEddie: "I don't like GUIs"

jjonj
Not too shy to talk
Not too shy to talk
Posts: 28
Joined: Fri Mar 21, 2014 22:11

Re: CEGUI initialisation causes flickering (ogre 2.0)

Postby jjonj » Sat Aug 08, 2015 11:48

It had already been fixed in ogre 2.1, and after i pointed it out they merged that fix into 2.0 https://bitbucket.org/sinbad/ogre/commi ... 7ee5f6166c

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

Re: CEGUI initialisation causes flickering (ogre 2.0)

Postby Ident » Sat Aug 08, 2015 12:34

Can you confirm that this solves all issues appearing in CEGUI? If so PLEASE edit the topic title by preceding it with "[Solved]"
CrazyEddie: "I don't like GUIs"


Return to “Help”

Who is online

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