Hi,
Say I have a wall with a name-plate on it. User can enter text from the application GUI. I want to display that text on the name-plate (which is a simple plane mesh). I'm lookin for ideas/suggestions how this could be achieved.
One way it could work is, to create an image from the text which user entered, and then apply that as texture to the plane mesh. This should work, only I dont know how to convert user-enterd text into an image. Is it possible?
Thanks in advance!
/regards
[SOLVED]Creating image from text
-
- Posts: 219
- Joined: Fri Feb 19, 2010 4:03 pm
- Location: Estonia
[SOLVED]Creating image from text
Last edited by xirtamatrix on Thu Apr 28, 2011 4:40 pm, edited 1 time in total.
to live, is natural; to die, is not!
Re: Creating image from text
Yes that would be the way I would implement such a feature.xirtamatrix wrote:One way it could work is, to create an image from the text which user entered, and then apply that as texture to the plane mesh. This should work, only I dont know how to convert user-enterd text into an image. Is it possible?
Take a look at the Render To Texture Tutorial. There you will find everything you need. Instead of drawing the whole scene you would just use an IGUIFont to draw the string
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
-
- Posts: 219
- Joined: Fri Feb 19, 2010 4:03 pm
- Location: Estonia
Re: Creating image from text
Thank You Sylence, but sorry I'm nor understanding.Sylence wrote:Take a look at the Render To Texture Tutorial. There you will find everything you need. Instead of drawing the whole scene you would just use an IGUIFont to draw the string
In case of rendering the scene to texture, we set a camera to look at the scene, and then draw to render target.
In our case, what is the camera supposed to look at? How and where do we draw the text?
I also cant understand where does the IGUIFont()->draw() supposed to draw the text?
Thanks.
to live, is natural; to die, is not!
If you need just to draw the text in 3d, you can use (or check the source how its done):
scene::ITextSceneNode
http://irrlicht.sourceforge.net/docu/cl ... _node.html
scene::ITextSceneNode
http://irrlicht.sourceforge.net/docu/cl ... _node.html
-
- Posts: 219
- Joined: Fri Feb 19, 2010 4:03 pm
- Location: Estonia
No, thank you, ITextSceneNode is not what I need. I mentioned explicitly that I need to show user-entered text on top of a plane mesh. What part of it is hard to understand?greenya wrote:If you need just to draw the text in 3d, you can use (or check the source how its done):
scene::ITextSceneNode
http://irrlicht.sourceforge.net/docu/cl ... _node.html
to live, is natural; to die, is not!
-
- Posts: 219
- Joined: Fri Feb 19, 2010 4:03 pm
- Location: Estonia
Never mind, I think I can use the code from this topic with some modifications.
Thanks to everyone who tried to help!
Thanks to everyone who tried to help!
to live, is natural; to die, is not!
You don't need any camera. Just do the following (pseudo code. Haven't worked with irrlicht since ages):
IGUIFont (or the whole GUI system) doesn't care about cameras since it's supposed to be a 2D overlay.
After the call to draw() the texture "renderTarget" will be a texture that has the rendered text in it. After that you can use the texture just like a texture that you loaded from a file.
Code: Select all
ITexture* renderTarget = driver->addRenderTargetTexture();
driver->setRenderTarget( renderTarget );
font->draw( L"Hello World" );
driver->setRenderTarget( 0 );
plane->setTexture( renderTarget );
smgr->drawAll();
After the call to draw() the texture "renderTarget" will be a texture that has the rendered text in it. After that you can use the texture just like a texture that you loaded from a file.
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
-
- Posts: 219
- Joined: Fri Feb 19, 2010 4:03 pm
- Location: Estonia
Wow, I did'nt see this before, that simplifies my task a lot!Sylence wrote:You don't need any camera. Just do the following (pseudo code. Haven't worked with irrlicht since ages):IGUIFont (or the whole GUI system) doesn't care about cameras since it's supposed to be a 2D overlay.Code: Select all
ITexture* renderTarget = driver->addRenderTargetTexture(); driver->setRenderTarget( renderTarget ); font->draw( L"Hello World" ); driver->setRenderTarget( 0 ); plane->setTexture( renderTarget ); smgr->drawAll();
After the call to draw() the texture "renderTarget" will be a texture that has the rendered text in it. After that you can use the texture just like a texture that you loaded from a file.
Thanks a LOT Sylence
to live, is natural; to die, is not!