2

I am trying to make a simple ui that has some text on it. I can create an empty panel and display that, however there is a runtime error when I try to create a TextAreaOverlayElement.

Error: OGRE EXCEPTIONS<5:ItemIdentityException>: Cannot locate factory for element type TextView in OverlayManager::createOverlayElement at ..........\Components\Overlay\src\OgreOverlayManager.cpp

This is the code I have created:

Ogre::OverlaySystem* pOverlaySystem = new Ogre::OverlaySystem();
ogre_root_->getSceneManager("MySceneManager")->addRenderQueueListener(pOverlaySystem);

std::cout << "Into ui init" << std::endl;
Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
std::cout << "Got singleton" << std::endl;

     // Create an overlay
     Ogre::Overlay* overlay = overlayManager.create( "OverlayName" );

     // Create a panel
     Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>( overlayManager.createOverlayElement( "Panel", "PanelName" ) );
     panel->setPosition( 0.5, 0.5);
     panel->setDimensions( 0.1, 0.1 );
     panel->setMaterialName( "BaseWhite" );
     // Add the panel to the overlay
     //Breaks on next line
     Ogre::TextAreaOverlayElement* text = (Ogre::TextAreaOverlayElement*)((Ogre::OverlayContainer*)overlayManager.createOverlayElement("TextView", "TextArea"));

     overlay->add2D( panel );

     // Show the overlay
     overlay->show();

If anyone knows what might be causing this or a workaround I would really appreciate it! I have been banging my head against the desk trying to figure this one out!

Ben Atkinson
  • 53
  • 1
  • 8

1 Answers1

0

The error says that it cannot find such overlay element factory as "TextView".

Which is absolutely true (unless you define one)

The signature of createOverlayElement is as follows (See reference manual of 1.9):

OverlayElement* Ogre::OverlayManager::createOverlayElement(
  const String& typeName, 
  const String &instanceName, 
  bool isTemplate = false
)

Thus, you should define overlay element type in the first place and your picked name as second.

Try the following for your case:

Ogre::TextAreaOverlayElement* text = 
  static_cast<Ogre::TextAreaOverlayElement*>(
  overlayManager.createOverlayElement("TextArea", "TextView"));

Also, you miss to add your text to your panel. Call

panel->addChild(text);
pergy
  • 5,285
  • 1
  • 22
  • 36