Displaying text and debugging

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
Raff1
Posts: 7
Joined: Tue Nov 03, 2009 11:09 pm

Displaying text and debugging

Post by Raff1 »

Hi! I am trying to display and update some text on the screen to read out some values for control and debugging. I am currently using
virtual IGUIStaticText = gui::IGUIEnvironment->addStaticText()
to do this. The text displays as it should, but I don't know how, or if its possible to edit the text contents. Since it is a static text class, I guess this is not the favorable way to do this anyways.

So what is the best way to display text I can easily update?

*Edit. Found some sticky information about debugging software i will be looking into.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You can change the text from your app, but it's not meant to be edited by the user of the app (in contrast to editbox)
Raff1
Posts: 7
Joined: Tue Nov 03, 2009 11:09 pm

Post by Raff1 »

hybrid wrote:You can change the text from your app, but it's not meant to be edited by the user of the app (in contrast to editbox)
Okey, thats just what I need.:) But my question is how I can change the text from the app. I could not recognize any function for that in the API.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

setText should be the way, unless I'm confused with other APIs.
mkEason
Posts: 5
Joined: Fri Nov 06, 2009 3:01 am

Post by mkEason »

hybrid wrote:setText should be the way, unless I'm confused with other APIs.
I am very new to irrlicht, I have the same problem to show dynamica text, may I ask that what object/class is "setText" belongs to?
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

setText is for static text.
static text doesnt mean that it can only have one value always, but means that the user can't change it.
you can change it any time from your app.

myText->setText(L"MyText");
Image
Image
mkEason
Posts: 5
Joined: Fri Nov 06, 2009 3:01 am

Post by mkEason »

B@z wrote:setText is for static text.
static text doesnt mean that it can only have one value always, but means that the user can't change it.
you can change it any time from your app.

myText->setText(L"MyText");
sorry for another stupid question....

I have no idea about where is "myText" comes from ?

so how can I display text by using my own defined variables ?
for example, I would like to display the name of some ISceneNode object on screen.

Code: Select all

ISceneNode* cube = smgr->addCubeSceneNode(50);
cube -> setName("cube");

guienv->addStaticText( smgr->getSceneNodeFromName("cube")->getName() , rect<s32>(10,10,260,22), true,false,0,1,false);
I get big error this way.
Can anybody kindly show me how to fix this?

THX a lot

:D
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

big error is not what I'd call a descriptive explanation. Please make sure you understand the basic C++ things needed for this situation, and post the full compiler message if you cannot figure it out.
mkEason
Posts: 5
Joined: Fri Nov 06, 2009 3:01 am

Post by mkEason »

hybrid wrote:big error is not what I'd call a descriptive explanation. Please make sure you understand the basic C++ things needed for this situation, and post the full compiler message if you cannot figure it out.
here is the error I got:

Code: Select all

ERROR	31	error C2664: 'irr::gui::IGUIEnvironment::addStaticText' : cannot convert parameter 1 from 'const irr::c8 *' to 'const wchar_t *'	d:\_development\irrlicht\_lab\57_proto_game\src\src\main.cpp	178	57_proto_game
I am also a newbie to c++ ... T_T

I realize that I need to convert c8 to wchar_t , I have already spent couple hours searching the solution, so far the results is too hard for me ... but it's ok, thanks for the remind anyway, I will keep finding it.

sorry for the "big error".
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ah yes, both interface methods use raw pointers, which doesn't help in automatic type conversions. write core::stringw(node->getName()).c_str()
mkEason
Posts: 5
Joined: Fri Nov 06, 2009 3:01 am

Post by mkEason »

hybrid wrote:Ah yes, both interface methods use raw pointers, which doesn't help in automatic type conversions. write core::stringw(node->getName()).c_str()
it works! Thanks a lot.
Post Reply