Font Draw - Sydney Tutorial

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
WhyMe
Posts: 10
Joined: Sat Jan 26, 2013 5:31 pm

Font Draw - Sydney Tutorial

Post by WhyMe »

Hello.

I'm new on this forum and with programming with using graphics engines. So, i want to say hello to everyone, and please forgive me my english.

Ok.

I modify HelloWorld tutorial with drawing an extern fonts, but, even if they are loaded, they aren't displayed. I trying with built in fonts and this is the same.

Code:

Code: Select all

device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
    IVideoDriver* driver = device->getVideoDriver();
    ISceneManager* smgr = device->getSceneManager();
    IGUIEnvironment* guienv = device->getGUIEnvironment();
 
   /*guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
         rect<s32>(10,10,260,52), true);*/
 
    IGUIFont *nFont = guienv->getBuiltInFont(); /* guienv->getFont("myfont.xml");*/
 
    if(nFont) nFont->draw(L"Testuje sobie bal bla", core::rect<s32>(10,10,260,52), video::SColor(0,0,0,0));
 
    IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");
        if (!mesh)
        {
            device->drop();
            return 1;
        }
Any advices ?
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Font Draw - Sydney Tutorial

Post by serengeor »

if(nFont) nFont->draw(L"Testuje sobie bal bla", core::rect<s32>(10,10,260,52), video::SColor(0,0,0,0));
Is that the only line where you do any drawing?
If so when your buffers get cleared (at beginScene?) and your text gets cleared from the screen. Or are you not using begin scene?

If so, use the draw function in main loop after buffers get cleared.
Working on game: Marrbles (Currently stopped).
WhyMe
Posts: 10
Joined: Sat Jan 26, 2013 5:31 pm

Re: Font Draw - Sydney Tutorial

Post by WhyMe »

I moved this line to the loop, but it didn't work ...

Code: Select all

#include <../../../../Qt/Qt5/X64/include/QtCore//QCoreApplication>
#include <../../../../Qt/Qt5/X64/include/Irrlicht/irrlicht.h>
 
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
 
 
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    
    IrrlichtDevice *device =
            createDevice( video::EDT_DIRECT3D9, dimension2d<u32>(640, 480), 32,
                false, false, false, 0);
 
        if (!device) return 1;
 
    device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
    IVideoDriver* driver = device->getVideoDriver();
    ISceneManager* smgr = device->getSceneManager();
    IGUIEnvironment* guienv = device->getGUIEnvironment();
 
   /*guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
         rect<s32>(10,10,260,52), true);*/
 
    IGUIFont *nFont = guienv->getBuiltInFont(); /* guienv->getFont("myfont.xml");*/
 
    IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");
        if (!mesh)
        {
            device->drop();
            return 1;
        }
    IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
 
    if (node)
        {
            node->setMaterialFlag(EMF_LIGHTING, false);
            node->setMD2Animation(scene::EMAT_STAND);
            node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
        }
 
    smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
 
    while(device->run())
        {
 
            driver->beginScene(true, true, SColor(255,100,101,140));
 
            if(nFont) nFont->draw(L"Testuje sobie bal bla", core::rect<s32>(10,10,260,52), video::SColor(0,0,0,0));
            smgr->drawAll();
            guienv->drawAll();
            driver->endScene();
        }
        device->drop();
 
    return a.exec();
}
 




//Edit:
Ok, thank you - it works, and I had set transparency.
Ruxify
Posts: 33
Joined: Tue Oct 16, 2012 12:37 am

Re: Font Draw - Sydney Tutorial

Post by Ruxify »

You should put the line after smgr->drawAll(). Otherwise, it will appear as if the text is behind all your 3D nodes.
Post Reply