我试图展示字母食人魔,但只是黑屏,我按照教程:http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Simple+Text+Output 我还没有清楚,因为我看不到屏幕上的字母,我没有得到编译错误。这是我的代码:
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;
}
我应该澄清一下我有一个媒体文件夹,其中保存了一个名为:MyFont.fontdef的文件是一个带字体的配置文件
MyFont
{
type truetype
source arial.ttf
size 16
resolution 72
}
答案 0 :(得分:0)
您的相机看起来配置不正确。尝试:
camera->setPosition(Ogre::Vector3(0,30,30));
camera->lookAt(Ogre::Vector3(0,0,0));