FPS in a text box.

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
Zedith
Posts: 5
Joined: Mon Oct 20, 2008 7:31 pm
Location: Estonia

FPS in a text box.

Post by Zedith »

I've added a text box with addStaticText and I want to put there realtime information about my current fps... But how should I do that?
I've added
guienv->addStaticText(str.c_str(),
rect<s32>(10,10,260,22), true);
to the loop but it creates after every loop a new static text box....

I've tried that way too.. It should work but it doesn't...

Code: Select all

Before loop
		int testfps=0;
		core::stringw str_fps = L"FPS @ ";
		str_fps+=testfps;

		guienv->addStaticText(str_fps.c_str(),rect<s32>(10,10,260,22), true);

After loop

            if (lastFPS != fps)
            {
				testfps=fps;
				lastFPS=fps;
			}
Maybe there's a way to refresh the GUI so that this textbox refreshes it's values?
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Re: FPS in a text box.

Post by rogerborg »

Image

SEW-KRATES ASKS:
Zedith wrote: guienv->addStaticText(str_fps.c_str(),rect<s32>(10,10,260,22), true);
Does IGUIEnvironment::addStaticText() return anything?

And the thing that it returns, what is that derived from?

And are there any methods of that class that might serve?

Image

PARTY ON, CODER DUDES!
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Zedith
Posts: 5
Joined: Mon Oct 20, 2008 7:31 pm
Location: Estonia

Post by Zedith »

Oh what a mistake.. Happens when coding 12pm(at my timezone).
I just added

gui::IGUIFont* font = device->getGUIEnvironment()->getBuiltInFont();

before loop and

core::stringw str = L"FPS @ ";
str += (s32)driver->getFPS();
if (font)
font->draw(str.c_str(),
core::rect<s32>(130,10,300,50),
video::SColor(255,255,255,255));

after loop.:P Easy.
I've been coding c++ only for 3 weeks(mostly console stuff).
Thanks for your help rogerborg.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

I didn't do anything, it was that Sew-krates dude, and his most excellent Method.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply