converting string and vector [solved]

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
noals
Posts: 70
Joined: Sun May 18, 2008 2:59 pm

converting string and vector [solved]

Post by noals »

hi,

i wanted to put the frame rate on screen (i use fullscreen) so i did a search and kinda get it working.
here is the code :

Code: Select all

    int lastFPS = -1;

    while(device->run())
    if (device->isWindowActive())
    {
        driver->beginScene(true, true, video::SColor(0,200,200,200));
        smgr->drawAll();


        int fps = driver->getFPS();
        if (lastFPS != fps)
        {
            core::stringw str = L"Irrlicht Engine - Quake 3 Map example [";
            str += driver->getName();
            str += "] FPS:";
            str += fps;
            device->setWindowCaption(str.c_str());
            lastFPS = fps;
        }

        IGUIEnvironment* guienv = device->getGUIEnvironment();
        IGUIStaticText* debug_panel = 
                guienv->addStaticText(L"Hello World",
                rect<s32>(5, 5, 200, 100),false,true,0,-1,false);
        s32 framerate = driver->getFPS();
        debug_panel->setText(stringw(framerate).c_str());

        device->getGUIEnvironment()->drawAll();
        driver->endScene();
    }
    device->drop();
    return 0;
my problem is that when the framerate come on screen, there is no refresh, the framerates are rendered on each other (sorry for my english) so i guess i should do something like :
if(framerate != 0) refresh the screen or something; but i dont really know how to do that.

i also put "vector" in the title because with this code, i kinda found a way to put a string previously set but what about vector ?
i mean, if for example i have something like setRotation(vector3df(0,0,0));, what should i use to write it kinda like setRotation(vector3df(myVector)); ?


thx
cya
Last edited by noals on Fri May 23, 2008 11:49 pm, edited 1 time in total.
radiant
Posts: 112
Joined: Fri Feb 22, 2008 8:04 pm
Location: Mexico

Post by radiant »

what u have to do is move the declaration of the static text variable ouside the main loop(get a pointer to it), and then instead of creating the static text inside the main loop just change the dysplayed text... like this:

Code: Select all

IGUIEnvironment* guienv = device->getGUIEnvironment();
IGUIStaticText* debug_panel =
        guienv->addStaticText(L"Hello World",
        rect<s32>(5, 5, 200, 100),false,true,0,-1,false);
int lastFPS = -1;

    while(device->run())
    if (device->isWindowActive())
    {
        driver->beginScene(true, true, video::SColor(0,200,200,200));
        smgr->drawAll();


        int fps = driver->getFPS();
        if (lastFPS != fps)
        {
            core::stringw str = L"Irrlicht Engine - Quake 3 Map example [";
            str += driver->getName();
            str += "] FPS:";
            str += fps;
            device->setWindowCaption(str.c_str());
            lastFPS = fps;
        }
        s32 framerate = driver->getFPS();
        debug_panel->setText(stringw(framerate).c_str());
        device->getGUIEnvironment()->drawAll();
        driver->endScene();
    }
    device->drop();
    return 0;
well something like that... i didnt compile that code but it should work... ir be very close to work =P

best regards
noals
Posts: 70
Joined: Sun May 18, 2008 2:59 pm

Post by noals »

well, it work fine, im kinda surprised it was so simple ^^;
thx

for the vector i think i found a way.
not a way to use vector but a way to have what i want.

i have the player, and a camera attached to it that move with the mouse.
i wanted to use the values returned and put them as the player->setRotation.
but, if im not wrong i just have to change the mouse control for it move the player node and no the camera one while the camera will still be attached to the player.

anyway, i will try that and i will do a new post if i cant get anything working.

thx for help.
cya
Post Reply