Hey, I want to print out a score or FPS, which will obviously have different 'text' each time.
I will use the IGUIFont object to draw, but I need to figure out how to format the text. In plain char* I would do sprintf(mystr, "Score: %d", myscore); .. how do i do it for WChar?
TIA
WChar functs
WChar functs
a screen cap is worth 0x100000 DWORDS
-
DarkWhoppy
- Posts: 386
- Joined: Thu Sep 25, 2003 12:43 pm
- Contact:
Is this what you're looking for?
Code: Select all
wchar_t _Info[1024];
int fps = Driver->getFPS();
swprintf(_Info, 1024,"FPS: %d ",fps);-
Serg Nechaeff
- Posts: 162
- Joined: Wed Nov 26, 2003 5:24 pm
- Location: Europe
Pick up my function:
plainn text:StringTextOut(font, 0 ,10, L"Programmed by Me" );
text + integer value
StringTextOut(font2, 0,20, L"Score: ", Score );
Code: Select all
void StringTextOut (gui::IGUIFont * font, int x, int y ,wchar_t text[], int d=-100)
{
wchar_t tmp [1024];
if (d==-100)
swprintf ( tmp, 1024, L"%s", text );
else
swprintf ( tmp, 1024, L"%s = %d", text, d );
font->draw ( tmp,
core::rect<s32>(x,y,300,80),
video::SColor(255,255,255,255));
}text + integer value
StringTextOut(font2, 0,20, L"Score: ", Score );
http://www.javazing.com
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
how about this one:
use it like this:
dout("There are %d ways to code a %s solution\n",10,"working");
just like a printf statement!
Code: Select all
void dout(const char *msg, ...)
{
va_list argList;
static char buffer[512] = { 0 }; //max 512 chars long
va_start(argList, msg);
vsprintf(buffer, msg, argList);
va_end(argList);
// do something with 'buffer'
// i send my debug output to a file but you can
// send to console via os::Printer::log(buffer);
// or to screen using font->draw
// if you need to turn it into a wchar_t then do this
// wchar_t text[512];
// mbstowcs(text,buffer,512);
}
dout("There are %d ways to code a %s solution\n",10,"working");
just like a printf statement!