The problem is, the first container with a TextAreaOverlayElement I try to add to an overlay doesn't appear. Subsequent ones appear fine. A minimal test case is as follows:
Code: Select all
OverlayContainer* textcontainer1;
OverlayContainer* textcontainer2;
TextAreaOverlayElement* textArea1;
TextAreaOverlayElement* textArea2;
Ogre::OverlayManager* m_pOverlayManager = Ogre::OverlayManager::getSingletonPtr();
Ogre::Overlay* pMapOverlay = m_pOverlayManager->create("MapOverlay");
textcontainer1 = static_cast<OverlayContainer*>(m_pOverlayManager->createOverlayElement("Panel", "TextContainer01"));
textcontainer1->setMetricsMode(Ogre::GMM_RELATIVE);
textcontainer1->setDimensions(0.4, 0.4);
textcontainer1->setPosition(0, 0);
textcontainer2 = static_cast<OverlayContainer*>(m_pOverlayManager->createOverlayElement("Panel", "TextContainer02"));
textcontainer2->setMetricsMode(Ogre::GMM_RELATIVE);
textcontainer2->setDimensions(0.4, 0.4);
textcontainer2->setPosition(0.5, 0.5);
textArea1 = static_cast<TextAreaOverlayElement*>(m_pOverlayManager->createOverlayElement("TextArea", "TextArea01"));
textArea1->setMetricsMode(Ogre::GMM_RELATIVE);
textArea1->setPosition(0, 0);
textArea1->setDimensions(0.4, 0.4);
textArea1->setCaption("Hello1");
textArea1->setCharHeight(0.05);
textArea1->setFontName("BlueHighway");
textArea2 = static_cast<TextAreaOverlayElement*>(m_pOverlayManager->createOverlayElement("TextArea", "TextArea02"));
textArea2->setMetricsMode(Ogre::GMM_RELATIVE);
textArea2->setPosition(0, 0);
textArea2->setDimensions(0.4, 0.4);
textArea2->setCaption("Hello2");
textArea2->setCharHeight(0.05);
textArea2->setFontName("BlueHighway");
textcontainer1->addChild(textArea1);
textcontainer2->addChild(textArea2);
pMapOverlay->add2D(textcontainer2);
pMapOverlay->add2D(textcontainer1);
pMapOverlay->show();
If I add yet more text areas they show up fine. It's just the first one I add that doesn't.
If anyone has any suggestions as to what I'm missing I'd be very grateful to hear them!
Edit: More information: Because I can't solve this bug, I use a work around where I add a dummy container with a TextAreaOverlayElement in it to the overlay before I do anything else. It doesn't display, of course, but anything I do subsequently does. The interesting thing is that this work around only succeeds if you set the font type (e.g. setParameter("font_name", "BlueHighway");) of the TextArea.
So the minimum one can do to to get later later text areas to show up is to add a container to the overlay, add a text area to the container, and set the font of the text area. Bizarre. This behaviour occurs if I drop the code into my project or a tutorial project. It also occurs if I use jacmoe's TextRenderer class here: http://www.ogre3d.org/tikiwiki/tiki-ind ... ext+Output. That is, I have to hack that class to add a dummy container with a dummy text area to the overlay before it works.