Cannot display TextArea in single Panel

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
User avatar
omniter
OGRE Contributor
OGRE Contributor
Posts: 424
Joined: Thu Mar 19, 2009 8:08 am
Location: Canada
x 44

Cannot display TextArea in single Panel

Post by omniter »

Hi guys,

I just found what appears to be a bug in the overlay system. It seems that when I have an overlay with one container in it, any TextArea elements inside of that container will not show. I have to add another container before it in the same overlay, containing another TextArea using the same font, so that the original one will show text. It sounds very strange, but I've tested it with a bunch of different fonts, materials, using templates / not using templates, etc. I am using the latest MogreSDK (which uses OGRE 1.7.1 revision 72), so I'm not sure if it's a Mogre-specific problem. Could someone else confirm / disconfirm this? Thanks!
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Cannot display TextArea in single Panel

Post by jacmoe »

I get the same error.
I think you can see it in the terrain sample as well.
Seems to be a refresh related issue, because it shows when the overlay is redrawn.
I think.. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
omniter
OGRE Contributor
OGRE Contributor
Posts: 424
Joined: Thu Mar 19, 2009 8:08 am
Location: Canada
x 44

Re: Cannot display TextArea in single Panel

Post by omniter »

Seems the problem was introduced in v1.7 then. :?
User avatar
omniter
OGRE Contributor
OGRE Contributor
Posts: 424
Joined: Thu Mar 19, 2009 8:08 am
Location: Canada
x 44

Re: Cannot display TextArea in single Panel

Post by omniter »

Hey guys,

I found a couple of other guys with similar problems. I didn't see the connection before, but it definitely seems like there is one now. Take a look at this thread.
MikkelBrun
Gnoblar
Posts: 3
Joined: Tue Jun 15, 2010 8:33 am

Re: Cannot display TextArea in single Panel

Post by MikkelBrun »

Seems like updateTextureGeometry isn't called properly at initialization.

I've been struggeling with this for quite a while, but thought it was a problem I caused myself..

Doing this, however.. does the trick:

Code: Select all

    bool first = true;

    while(mRunning)
    {
        //Pump messages in all registered RenderWindow windows
        Ogre::WindowEventUtilities::messagePump();
        mRoot->renderOneFrame(); // Ignore whatever the frame listeners return basically.

        if(first)
        {
            first = false;

            // Simple hack to make sure all text area overlay elements are shown correctly..

            Ogre::OverlayManager& om = Ogre::OverlayManager::getSingleton();

            Ogre::OverlayManager::OverlayMapIterator omi = om.getOverlayIterator();
            while(omi.hasMoreElements())
            {
                Ogre::Overlay* overlay = omi.getNext();
                Ogre::Overlay::Overlay2DElementsIterator o2dei = overlay->get2DElementsIterator();
                while(o2dei.hasMoreElements())
                {
                    Ogre::OverlayElement* oe = o2dei.getNext();
                    oe->setCaption(oe->getCaption());
                }

            }
        }
    }
It's obviously not ment to be done this way though.
TaeHyungKim
Kobold
Posts: 31
Joined: Thu Jun 03, 2010 4:03 pm
Location: Korea

Re: Cannot display TextArea in single Panel

Post by TaeHyungKim »

i replied for this problem earlier another thread..
I think this is bug in OverlayElement::_update(void) function,
mPixelWidth is changed at line (1) , but mWidth is changed at line (2)
but at line (3) mGeomPositionsOutOfDate is setting to false, so when next _update fuction called, line (2) is not excuted because (4) is false
mWidth is not changed at this time, so textarea is not displayed

Code: Select all

-> OgreOverlayElement.cpp 

    void OverlayElement::_update(void)
    {
        // Check size if pixel-based
        switch (mMetricsMode)
        {
        case GMM_PIXELS :
            if (OverlayManager::getSingleton().hasViewportChanged() || mGeomPositionsOutOfDate)  // (4)
            {
                Real vpWidth, vpHeight;
                OverlayManager& oMgr = OverlayManager::getSingleton();
                vpWidth = (Real) (oMgr.getViewportWidth());
                vpHeight = (Real) (oMgr.getViewportHeight());

                mPixelScaleX = 1.0f / vpWidth;
                mPixelScaleY = 1.0f / vpHeight;

                mLeft = mPixelLeft * mPixelScaleX;
                mTop = mPixelTop * mPixelScaleY;
                mWidth = mPixelWidth * mPixelScaleX;                                                 // (2)
                mHeight = mPixelHeight * mPixelScaleY;
            }
            break;

        case GMM_RELATIVE_ASPECT_ADJUSTED :
            if (OverlayManager::getSingleton().hasViewportChanged() || mGeomPositionsOutOfDate)
            {
                Real vpWidth, vpHeight;
                OverlayManager& oMgr = OverlayManager::getSingleton();
                vpWidth = (Real) (oMgr.getViewportWidth());
                vpHeight = (Real) (oMgr.getViewportHeight());

                mPixelScaleX = 1.0f / (10000.0f * (vpWidth / vpHeight));
                mPixelScaleY = 1.0f /  10000.0f;

                mLeft = mPixelLeft * mPixelScaleX;
                mTop = mPixelTop * mPixelScaleY;
                mWidth = mPixelWidth * mPixelScaleX;
                mHeight = mPixelHeight * mPixelScaleY;
            }
            break;
        default:
            break;
        }

        _updateFromParent();
        // NB container subclasses will update children too

        // Tell self to update own position geometry
        if (mGeomPositionsOutOfDate && mInitialised)
        {
            updatePositionGeometry();                                                       // (1)
            mGeomPositionsOutOfDate = false;                                           // (3)
        }
        // Tell self to update own texture geometry
       if (mGeomUVsOutOfDate && mInitialised)
       {
	updateTextureGeometry();
	mGeomUVsOutOfDate = false;
       }
}
User avatar
omniter
OGRE Contributor
OGRE Contributor
Posts: 424
Joined: Thu Mar 19, 2009 8:08 am
Location: Canada
x 44

Re: Cannot display TextArea in single Panel

Post by omniter »

So does that mean the problem doesn't occur for relative metrics mode?
TaeHyungKim
Kobold
Posts: 31
Joined: Thu Jun 03, 2010 4:03 pm
Location: Korea

Re: Cannot display TextArea in single Panel

Post by TaeHyungKim »

i don't know what is relative metircs mode..
i just initialize buttons like this

m_pTrayMgr = new OgreBites::MySDKTrayManager("TrayMgr", m_pRenderWnd, m_pMouse, this);
m_pTrayMgr->showCursor();
m_pTrayMgr->createButton(OgreBites::TL_BOTTOMRIGHT,"_Continue","Continue",140.0f);

caption is not displaying always.

in my update fuction, i called below code at each frame
button->setCaption("Continue");
after this , caption is display well , mWidth value is corrected.
User avatar
omniter
OGRE Contributor
OGRE Contributor
Posts: 424
Joined: Thu Mar 19, 2009 8:08 am
Location: Canada
x 44

Re: Cannot display TextArea in single Panel

Post by omniter »

The SdkTrays system uses pixel metrics mode.
If you are correct, then the fix could be just to put the switch statement between lines (1) and (3).
User avatar
icaro56
Greenskin
Posts: 105
Joined: Sun Feb 15, 2009 2:03 am
Location: Belo Horizonte, MG, BRA
x 1

Re: Cannot display TextArea in single Panel

Post by icaro56 »

I get the same error!

In my topic: http://www.ogre3d.org/forums/viewtopic.php?f=5&t=61763


This is strange!
Ícaro Motta
GemX
Gnoblar
Posts: 6
Joined: Wed Jul 20, 2011 10:45 am
x 3

Re: Cannot display TextArea in single Panel

Post by GemX »

Try using this:

Code: Select all

  // load fonts explicitly after resources are loaded (esp. SdkTray.zip) since they will not be loaded on start up from the resource manager
  ResourceManager::ResourceMapIterator iter = Ogre::FontManager::getSingleton().getResourceIterator();
  while (iter.hasMoreElements()) { iter.getNext()->load(); }
Fonts are not loaded correctly in the first run... So add these lines at startup after you loaded your resources (esp. SdkTray.zip)!
I had this problem with sliders, labels, buttons and so forth.
User avatar
omniter
OGRE Contributor
OGRE Contributor
Posts: 424
Joined: Thu Mar 19, 2009 8:08 am
Location: Canada
x 44

Re: Cannot display TextArea in single Panel

Post by omniter »

A couple of fixes have been posted a long time ago:
http://www.ogre3d.org/forums/viewtopic. ... 75#p403274
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Cannot display TextArea in single Panel

Post by jacmoe »

That's not really impressive, as it didn't went into the code base, but it's better than nothing. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
TaeHyungKim
Kobold
Posts: 31
Joined: Thu Jun 03, 2010 4:03 pm
Location: Korea

Re: Cannot display TextArea in single Panel

Post by TaeHyungKim »

omniter wrote:The SdkTrays system uses pixel metrics mode.
If you are correct, then the fix could be just to put the switch statement between lines (1) and (3).
you're right. i modify that you said "put the switch statement between lines (1) and (3)".

caption is viewed well.
thanks. i hope this fix is reflected in ogre next version.
guillaumequest
Kobold
Posts: 32
Joined: Thu Aug 11, 2011 10:00 pm

Re: Cannot display TextArea in single Panel

Post by guillaumequest »

Hello,
I believe I'm still having this bug, but I'm not using SdkTrays, just overlays directly, and all the fixes use SdkTrays. Do you know if there are some other fixes available ?

Thanks for your help,
Guillaume
User avatar
omniter
OGRE Contributor
OGRE Contributor
Posts: 424
Joined: Thu Mar 19, 2009 8:08 am
Location: Canada
x 44

Re: Cannot display TextArea in single Panel

Post by omniter »

guillaumequest wrote:Hello,
I believe I'm still having this bug, but I'm not using SdkTrays, just overlays directly, and all the fixes use SdkTrays. Do you know if there are some other fixes available ?

Thanks for your help,
Guillaume
If you're compiling Ogre, you can look up a few posts for a solution that involves changing OgreOverlayElement.cpp.
Also, from the other threads: "Any operation that will cause the OverlayElement's geom positions to be refreshed will fix this problem."
This includes stuff like changing positions and sizes, and setting the metrics mode.
guillaumequest
Kobold
Posts: 32
Joined: Thu Aug 11, 2011 10:00 pm

Re: Cannot display TextArea in single Panel

Post by guillaumequest »

Thanks,
I copied the code from ObjectTextDisplay and adapted it so that it would display the text at a fixed position and this worked for some reason, I don't really have any idea why that worked better, though...
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 135
Contact:

Re: Cannot display TextArea in single Panel

Post by spacegaier »

FYI for everyone coming across this issue and this thread: I just fixed the problem in both the 1.8 and 1.9 branch. So if you run into the described situation please update your Ogre version/revision.
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
User avatar
arcanemartz
Gnoblar
Posts: 6
Joined: Tue Jun 26, 2012 11:38 pm
x 3
Contact:

Re: Cannot display TextArea in single Panel

Post by arcanemartz »

Hi,

It seems the patch has broken the ability to update the position of an overlay element with setPosition(...) when element is in relative mode. It seems the switch case in _update() should be similar to the one in _notifyViewport(), i.e. add to the default case:

Code: Select all

        case GMM_RELATIVE :
            mPixelScaleX = 1.0;
            mPixelScaleY = 1.0;
            mPixelLeft = mLeft;
            mPixelTop = mTop;
            mPixelWidth = mWidth;
            mPixelHeight = mHeight;
Here is the complete switch in _update():

Code: Select all

        // Check size if pixel-based or relative-aspect-adjusted
        switch (mMetricsMode)
        {
        case GMM_PIXELS :
            if (OverlayManager::getSingleton().hasViewportChanged() || mGeomPositionsOutOfDate)
            {               
                mPixelScaleX = 1.0f / vpWidth;
                mPixelScaleY = 1.0f / vpHeight; 
            }
            break;

        case GMM_RELATIVE_ASPECT_ADJUSTED :
            if (OverlayManager::getSingleton().hasViewportChanged() || mGeomPositionsOutOfDate)
            {
                mPixelScaleX = 1.0f / (10000.0f * (vpWidth / vpHeight));
                mPixelScaleY = 1.0f /  10000.0f;
            }
            break;

        default:
        case GMM_RELATIVE :
            mPixelScaleX = 1.0;
            mPixelScaleY = 1.0;
            mPixelLeft = mLeft;
            mPixelTop = mTop;
            mPixelWidth = mWidth;
            mPixelHeight = mHeight;
            break;
        }
Thanks,
Martin
Post Reply