Dynamic text with getGUIEnvironment()->getFont()

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
AnX
Posts: 7
Joined: Mon Jan 12, 2004 8:25 pm
Location: Brazil

Dynamic text with getGUIEnvironment()->getFont()

Post by AnX »

Very beginner question:
Now my code is:

Code: Select all

// Console Begin

s32 fps;
fps = driver->getFPS();

driver->draw2DRectangle(SColor(100,0,0,0),rect<s32>(0,565,800,600));
	
font->draw(L"This is some text.",	// Text
	rect<s32>(0,565,800,600),	// Position
	SColor(100,255,255,255)		// Color
	);

// Console End
How can I update "This is some text." with my fps var ?
"We are all lost, like tears in the rain and the water from above kills the eternal flame"
AnX
Posts: 7
Joined: Mon Jan 12, 2004 8:25 pm
Location: Brazil

Post by AnX »

Solved the problem using swprintf();
Thanks to all.
"We are all lost, like tears in the rain and the water from above kills the eternal flame"
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

since the string is in wchar_t format (instaed of just char) you need to get the fps (as an int) and print it to wchar_t using something like sprintf for wide chars.

look for a function like wsprintf()

then:
wchar_t _Info[64];
wsprintf(_Info, "FPS: %d", driver->getFPS() );
font->draw( _Info, yada yada );
a screen cap is worth 0x100000 DWORDS
Post Reply