Creating Overlays via Code         Without using overlay scripts
Print

Ogre 1.7
Ogre 1.6
This code snippet demonstrates how to create Overlays? using code.

 
You'll need to include OgreTextAreaOverlayElement.h and OgreFontManager.h for this snippet to compile.


OverlayManager& overlayManager = OverlayManager::getSingleton();
 
// Create a panel
OverlayContainer* panel = static_cast<OverlayContainer*>(
    overlayManager.createOverlayElement("Panel", "PanelName"));
panel->setMetricsMode(Ogre::GMM_PIXELS);
panel->setPosition(10, 10);
panel->setDimensions(100, 100);
//panel->setMaterialName("MaterialName"); // Optional background material
 
// Create a text area
TextAreaOverlayElement* textArea = static_cast<TextAreaOverlayElement*>(
    overlayManager.createOverlayElement("TextArea", "TextAreaName"));
textArea->setMetricsMode(Ogre::GMM_PIXELS);
textArea->setPosition(0, 0);
textArea->setDimensions(100, 100);
textArea->setCaption("Hello, World!");
textArea->setCharHeight(16);
textArea->setFontName("TrebuchetMSBold");
textArea->setColourBottom(ColourValue(0.3, 0.5, 0.3));
textArea->setColourTop(ColourValue(0.5, 0.7, 0.5));
 
// Create an overlay, and add the panel
Overlay* overlay = overlayManager.create("OverlayName");
overlay->add2D(panel);
 
// Add the text area to the panel
panel->addChild(textArea);
 
// Show the overlay
overlay->show();

 

See also


Alias: Creating_Overlays_via_Code


Contributors to this page: DragonM728 points  , Spacegaier3733 points  , JustBoo and jacmoe111451 points  .
Page last modified on Tuesday 31 of August, 2010 20:13:07 GMT by DragonM728 points .


The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.
As an exception, any source code contributed within the content is released into the Public Domain.