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.

Cannot display TextArea in single Panel

Postby omniter » Wed Jul 21, 2010 6:27 am

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
omniter
OGRE Contributor
OGRE Contributor
 
Posts: 424
Kudos: 44
Joined: 19 Mar 2009
Location: Canada

Re: Cannot display TextArea in single Panel

Postby jacmoe » Wed Jul 21, 2010 4:40 pm

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
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 20570
Kudos: 181
Joined: 22 Jan 2004
Location: Denmark

Re: Cannot display TextArea in single Panel

Postby omniter » Wed Jul 21, 2010 6:11 pm

Seems the problem was introduced in v1.7 then. :?
User avatar
omniter
OGRE Contributor
OGRE Contributor
 
Posts: 424
Kudos: 44
Joined: 19 Mar 2009
Location: Canada

Re: Cannot display TextArea in single Panel

Postby omniter » Mon Aug 02, 2010 2:30 pm

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.
User avatar
omniter
OGRE Contributor
OGRE Contributor
 
Posts: 424
Kudos: 44
Joined: 19 Mar 2009
Location: Canada

Re: Cannot display TextArea in single Panel

Postby MikkelBrun » Tue Aug 10, 2010 2:14 pm

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.
MikkelBrun
Gnoblar
 
Posts: 3
Kudos: 0
Joined: 15 Jun 2010

Re: Cannot display TextArea in single Panel

Postby TaeHyungKim » Wed Aug 18, 2010 1:06 pm

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;
       }
}
TaeHyungKim
Kobold
 
Posts: 31
Kudos: 0
Joined: 03 Jun 2010
Location: Korea

Re: Cannot display TextArea in single Panel

Postby omniter » Wed Aug 18, 2010 11:23 pm

So does that mean the problem doesn't occur for relative metrics mode?
User avatar
omniter
OGRE Contributor
OGRE Contributor
 
Posts: 424
Kudos: 44
Joined: 19 Mar 2009
Location: Canada

Re: Cannot display TextArea in single Panel

Postby TaeHyungKim » Thu Aug 19, 2010 7:31 pm

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.
TaeHyungKim
Kobold
 
Posts: 31
Kudos: 0
Joined: 03 Jun 2010
Location: Korea

Re: Cannot display TextArea in single Panel

Postby omniter » Thu Aug 19, 2010 11:36 pm

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
omniter
OGRE Contributor
OGRE Contributor
 
Posts: 424
Kudos: 44
Joined: 19 Mar 2009
Location: Canada

Re: Cannot display TextArea in single Panel

Postby icaro56 » Thu Dec 02, 2010 8:03 pm

I get the same error!

In my topic: viewtopic.php?f=5&t=61763


This is strange!
Ícaro Motta
User avatar
icaro56
Greenskin
 
Posts: 105
Kudos: 1
Joined: 15 Feb 2009
Location: Belo Horizonte, MG, BRA

Re: Cannot display TextArea in single Panel

Postby GemX » Wed Jul 20, 2011 10:51 am

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.
GemX
Gnoblar
 
Posts: 6
Kudos: 3
Joined: 20 Jul 2011

Re: Cannot display TextArea in single Panel

Postby omniter » Thu Aug 04, 2011 3:23 pm

A couple of fixes have been posted a long time ago:
viewtopic.php?f=2&t=59372&p=403275#p403274
User avatar
omniter
OGRE Contributor
OGRE Contributor
 
Posts: 424
Kudos: 44
Joined: 19 Mar 2009
Location: Canada

Re: Cannot display TextArea in single Panel

Postby jacmoe » Thu Aug 04, 2011 4:08 pm

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.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 20570
Kudos: 181
Joined: 22 Jan 2004
Location: Denmark

Re: Cannot display TextArea in single Panel

Postby TaeHyungKim » Tue Oct 25, 2011 5:20 am

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.
TaeHyungKim
Kobold
 
Posts: 31
Kudos: 0
Joined: 03 Jun 2010
Location: Korea

Re: Cannot display TextArea in single Panel

Postby guillaumequest » Mon Dec 19, 2011 8:21 am

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
guillaumequest
Kobold
 
Posts: 32
Kudos: 0
Joined: 11 Aug 2011

Re: Cannot display TextArea in single Panel

Postby omniter » Mon Dec 19, 2011 9:52 am

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.
User avatar
omniter
OGRE Contributor
OGRE Contributor
 
Posts: 424
Kudos: 44
Joined: 19 Mar 2009
Location: Canada

Re: Cannot display TextArea in single Panel

Postby guillaumequest » Mon Dec 19, 2011 10:34 am

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...
guillaumequest
Kobold
 
Posts: 32
Kudos: 0
Joined: 11 Aug 2011

Re: Cannot display TextArea in single Panel

Postby spacegaier » Mon Feb 11, 2013 12:58 am

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
spacegaier
OGRE Team Member
OGRE Team Member
 
Posts: 4291
Kudos: 126
Joined: 04 Feb 2008
Location: Germany

Re: Cannot display TextArea in single Panel

Postby arcanemartz » Fri Mar 22, 2013 2:19 am

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
User avatar
arcanemartz
Gnoblar
 
Posts: 6
Kudos: 3
Joined: 26 Jun 2012


Return to Developer talk

Who is online

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