using strings with font->draw()

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
Error1312
Posts: 23
Joined: Fri Dec 26, 2003 8:32 pm
Location: Belgium

using strings with font->draw()

Post by Error1312 »

Hello everybody.

I want to store user input in a string, but I have problems putting the string on the screen. This is my font->draw() function (where text is my string):

font->draw(L + text,core::rect<s32>(10,10,100,50),video::SColor(0,0,255,0));


The compiler says that 'L' is not identified. I've tried it with a few other notations too, but it doesn't work. Is there any way to get rid of the 'L' so you can just put the name of your string in the function?

Thanks in advance?
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

Are you thinking of L as in L""?

When a character array(string) has an L before it, that means that it is not a normal char, but a wide char (wchar_t).

So L"hiya" != "hiya".

You would have to use a conversion like mbstowcs()

Code: Select all

#include <string.h>

char InText[255];
wchar_t OutText[255];
mbstowcs(OutText,InText,255);
Crud, how do I do this again?
Error1312
Posts: 23
Joined: Fri Dec 26, 2003 8:32 pm
Location: Belgium

Post by Error1312 »

I'm thinking about L like in the font->draw code. Just like this example:

font->draw(L"Hello World",core::rect<s32>(10,10,100,50),video::SColor(0,0,255,0));

Anyway, I want to try your solution, but the compiler says that
mbstowcs is an undeclared identifier. I've included the string.h file, but it keeps giving the error. What am I doing wrong?
Error1312
Posts: 23
Joined: Fri Dec 26, 2003 8:32 pm
Location: Belgium

Post by Error1312 »

Never mind about my last post. I've found the solution: you have to include <stdlib.h> in your project. Thanks for your help. :D

Now I've got another question. How would you make a console like in Quake or like DOS. I can't find a way to keep the previous typed letters in memory. I always have to redraw them (which doesn't really wanna work either).
Post Reply