I'm trying to show letters ogre but only get a black screen and I followed a tutorial: http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Simple+Text+Output I have not yet clear because I can not see the letters on the screen, I do not get compile errors. This is the code that I have:
int main(int argc, char *argv[])
{
Root* root = new Ogre::Root("config/plugins.cfg", "config/ogre.cfg", "config/ogre.log");
check_config(root);
RenderWindow* window = root->initialise(true, "Titulo"); // crea la ventana
SceneManager* scene_manager = root->createSceneManager(ST_GENERIC, "SceneManager"); //crea el scene
load_resources("config/resources.cfg");
Camera* camera = root->getSceneManager("SceneManager")->createCamera("Camera"); //inicializo la camara
Viewport* viewport = root->getAutoCreatedWindow()->addViewport(camera); //inicializo camara
// get the resource manager
ResourceGroupManager &resGroupMgr = ResourceGroupManager::getSingleton();
// tell it to look at this location
resGroupMgr.addResourceLocation("media", "media");
// get the font manager
FontManager &fontMgr = FontManager::getSingleton();
// create a font resource
ResourcePtr font = fontMgr.create("MyFont","General");
// set as truetype
font->setParameter("type","truetype");
// set the .ttf file name
font->setParameter("source","MyFont.fontdef");
// set the size
font->setParameter("size","26");
// set the dpi
font->setParameter("resolution","96");
// load the ttf
font->load();
//create_light(root);
OverlayManager& overlayMgr = OverlayManager::getSingleton();
Ogre::OverlayContainer* panel = static_cast<OverlayContainer*>(
overlayMgr.createOverlayElement("Panel", "PanelName"));
panel->setMetricsMode(Ogre::GMM_PIXELS);
panel->setPosition(10, 10);
panel->setDimensions(300, 120);
TextAreaOverlayElement* textArea = static_cast<TextAreaOverlayElement*>(
overlayMgr.createOverlayElement("TextArea", "TextAreaName"));
textArea->setMetricsMode(Ogre::GMM_PIXELS);
textArea->setPosition(0, 0);
textArea->setDimensions(300, 120);
textArea->setCharHeight(26);
// set the font name to the font resource that you just created.
textArea->setFontName("MyFont");
// say something
textArea->setCaption("Hello, World!");
Ogre::Overlay* overlay = overlayMgr.create("OverlayName");
overlay->add2D(panel);
panel->addChild(textArea);
overlay->show();
root->startRendering();
delete window;
delete scene_manager;
delete root;
return 0;
}
I should clarify that I have a media folder where saved a file named: MyFont.fontdef is a configuration file with font
MyFont
{
type truetype
source arial.ttf
size 16
resolution 72
}
It looks like your camera isn't configured properly. Try:
camera->setPosition(Ogre::Vector3(0,30,30));
camera->lookAt(Ogre::Vector3(0,0,0));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.