right, i built the demo you made, and that worked fine with whatever fonts I threw at it, loaded from the current directory.
Now I have another problem.
I have the exact same thing setup in my main app I'm writing, but when I call the font->draw(blah, blah, blah) it dies. I traced the fault down to when it calls 'FT_Get_Char_Index' in the 'getGlyphByChar' function.
I don't know why this is happening though. Here is the code for the class that has it in:
CDemoIntro.h
Code: Select all
#include <CDemoStage.h>
#include <irrlicht.h>
#include <CGUITTFont.h>
class CDemoIntroEvents;
class CDemoIntro : public CDemoStage {
public:
CDemoIntro(IrrlichtDevice * device);
~CDemoIntro();
// Methods
int run();
void quit();
virtual bool OnEvent(irr::SEvent event);
private:
gui::CGUITTFont * font;
video::ITexture* irrlichtLogo;
video::ITexture* darkliquid;
scene::IMesh * mesh;
scene::IAnimatedMesh * hillplane;
};
and
CDemoIntro.cpp
Code: Select all
#include <CDemoIntro.h>
#include <CGUITTFont.h>
#include <irrlicht.h>
#include <iostream>
using namespace irr;
CDemoIntro::CDemoIntro(IrrlichtDevice * device)
{
//Initialise all the variables
driver = device->getVideoDriver();
timer = device->getTimer();
smgr = device->getSceneManager();
gui = device->getGUIEnvironment();
fader = device->getGUIEnvironment()->addInOutFader(); // must come after gui init
running=0; // tell the main app that the demo is now running (0 = true, 1 = false)
quitting=false;
scene::ISceneNode * root = smgr->getRootSceneNode();
// Add a camera
smgr->addCameraSceneNode(0,core::vector3df(-250,200,-250),core::vector3df(0,-400,0));
// Load font
//font = gui->getFont("../media/fonthaettenschweiler.bmp");
font = new gui::CGUITTFont(driver);
gui::CGUITTFace face;
if(face.load("../media/battle3.ttf"))
std::cout << "Loaded font face..." << std::endl;
font->attach(&face,24);
//font->TransParency=true;
//font->AntiAlias=true;
std::cout << "Attached font face..." << std::endl;
// Set start time for demo
sceneStartTime = timer->getTime();
timeForThisStage = 14000;
// Load the textures
irrlichtLogo = driver->getTexture("../media/irrlichtlogo.bmp");
darkliquid = driver->getTexture("../media/darkliquid.bmp");
driver->makeColorKeyTexture(darkliquid,core::position2d<int>(0,0));
// Scene manager fancy stuff
std::cout << "mesh..." << std::endl;
hillplane = smgr->addHillPlaneMesh("myHill",
core::dimension2d<f32>(20,20),
core::dimension2d<s32>(40,40), 0, 0,
core::dimension2d<f32>(0,0),
core::dimension2d<f32>(10,10));
std::cout << "mesh2..." << std::endl;
mesh = smgr->getMesh("myHill")->getMesh(0);
std::cout << "node..." << std::endl;
scene::ISceneNode * node = smgr->addWaterSurfaceSceneNode(mesh, 3.0f, 300.0f, 30.0f,root);
node->setPosition(core::vector3df(0,0,0));
node->setMaterialTexture(0,driver->getTexture("../media/water.jpg"));
node->setMaterialTexture(1,driver->getTexture("../media/stones.jpg"));
node->setMaterialType(video::EMT_REFLECTION_2_LAYER);
std::cout << "node2..." << std::endl;
scene::ISceneNode * lightnode = smgr->addLightSceneNode(root,core::vector3df(0,0,0),video::SColorf(1.0f,0.6f,0.7f,1.0f),600.0f);
scene::ISceneNodeAnimator* anim=0;
anim=smgr->createFlyCircleAnimator(core::vector3df(0,150,0),200.0f);
lightnode->addAnimator(anim);
anim->drop();
// Setup the InOutFader
fader->setColor(video::SColor(0,0,0,0));
fader->fadeIn(2000);
}
CDemoIntro::~CDemoIntro()
{
// TODO: put destructor code here
std::cout << "Deallocating resources..." << std::endl;
smgr->getRootSceneNode()->removeAll();
font->drop();
fader->remove();
irrlichtLogo->drop();
darkliquid->drop();
driver->removeAllTextures();
}
int CDemoIntro::run() {
if(((timer->getTime()-sceneStartTime)>timeForThisStage) && timeForThisStage != -1 || quitting) {
quit();
}
smgr->drawAll();
driver->draw2DRectangle(video::SColor(128,255,255,255),core::rect<s32>(0,375,640,425));
driver->draw2DImage(irrlichtLogo,core::position2d<int>(10,10));
font->draw(L"Hello TrueType",core::rect<s32>(0,240,640,240),video::SColor(128,255,64,64),true);
//driver->draw2DImage(darkliquid,core::position2d<int>(280,340),core::rect<s32>(0,0,360,140),0,video::SColor(128,32,255,32),false);
gui->drawAll();
return running;
}
void CDemoIntro::quit() {
if(!quitting && fader->isReady()) {
fader->fadeOut(2000);
quitting=true;
}
if (fader->isReady()) {
std::cout << "End of demo..." << std::endl;
running=1;
}
}
bool CDemoIntro::OnEvent(SEvent event) {
if (event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_ESCAPE &&
event.KeyInput.PressedDown == false)
{
// user wants to quit.
quit();
}
return false;
}