How to render text?
-
myak
- Halfling
- Posts: 40
- Joined: Fri May 23, 2003 10:46 pm
- Location: Warsaw, Poland
How to render text?
My question is (I think) quite simple to answer: how to render text using a specified font to a texture?
Marcin Jakubowski
jabber://myak@chrome.pl
jabber://myak@chrome.pl
-
sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67
-
myak
- Halfling
- Posts: 40
- Joined: Fri May 23, 2003 10:46 pm
- Location: Warsaw, Poland
Can you please point me where to look for the example? I guess it's somewhere in the GUI/Overlay-related code but I can't find it.sinbad wrote:you could FreeType directly, like we do.
The closest match I've found is TextAreaOverlayElement::updateGeometry() but it's not really what I'm looking for. I want to have Texture object which I can use in TextureUnitState to define new Material.
PS. Reading the documentation online is not nice because of messed CSS styles.. :/
Marcin Jakubowski
jabber://myak@chrome.pl
jabber://myak@chrome.pl
-
DWORD
- OGRE Retired Moderator

- Posts: 1365
- Joined: Tue Sep 07, 2004 12:43 pm
- Location: Aalborg, Denmark
-
myak
- Halfling
- Posts: 40
- Joined: Fri May 23, 2003 10:46 pm
- Location: Warsaw, Poland
Thanks
I think it will really help me.. at least when I finally understand it
)
Marcin Jakubowski
jabber://myak@chrome.pl
jabber://myak@chrome.pl
-
myak
- Halfling
- Posts: 40
- Joined: Fri May 23, 2003 10:46 pm
- Location: Warsaw, Poland
Ok, using FreeType gives me an extra dependency in my project and I can't use it..
So what I have left is RenderTexture, which I really have no idea how to use. I looked at RenderToTexture sample and here's what my doubts are:
1. RenderTexture is updated every frame, am I right? I need it to render once at the loading stage of my game and then I want to assign that texture to a entity. And that's all
How to set it up that way?
2. On the viewport I created for the camera I'm using for RenderTexture I have to show an overlay with my text fitting entire viewport, right? So I have to create an overlay and call showOverlays(false) on my main viewport and showOverlays(true) on that I'm using for rendertexture, right?
3. And I have to repeat these things N times if I want to create N textures?
There has to be an easier way
I'm not very familiar with RenderTextures. Ok, I'm not at all familiar with them.. so if anyone has a better idea, please share 
So what I have left is RenderTexture, which I really have no idea how to use. I looked at RenderToTexture sample and here's what my doubts are:
1. RenderTexture is updated every frame, am I right? I need it to render once at the loading stage of my game and then I want to assign that texture to a entity. And that's all
2. On the viewport I created for the camera I'm using for RenderTexture I have to show an overlay with my text fitting entire viewport, right? So I have to create an overlay and call showOverlays(false) on my main viewport and showOverlays(true) on that I'm using for rendertexture, right?
3. And I have to repeat these things N times if I want to create N textures?
There has to be an easier way
Marcin Jakubowski
jabber://myak@chrome.pl
jabber://myak@chrome.pl
-
DWORD
- OGRE Retired Moderator

- Posts: 1365
- Joined: Tue Sep 07, 2004 12:43 pm
- Location: Aalborg, Denmark
Why can't you use it? Ogre already does, but I think it's statically linked.myak wrote:Ok, using FreeType gives me an extra dependency in my project and I can't use it..
Edit:
This doesn't sound like it needs to be dynamic, but I guess it's not the same text every time you start the game, or...? Otherwise you could just make a texture with the text on it in Gimp or something. But you probably thought about that.myak wrote:I need it to render once at the loading stage of my game and then I want to assign that texture to a entity. And that's allHow to set it up that way?
-
myak
- Halfling
- Posts: 40
- Joined: Fri May 23, 2003 10:46 pm
- Location: Warsaw, Poland
Hmm, that sounds like a good ideaDWORD wrote:Why can't you use it? Ogre already does, but I think it's statically linked.
[EDIT]
Checked. Doesn't work
Code: Select all
FT_Library ftLibrary;
FT_Init_FreeType( &ftLibrary );
FT_Done_FreeType(ftLibrary);[/EDIT]
Yeah, I thought about that. But including 200 textures would dramatically increase download size. What I want is when user runs the game for the first time textures are generated and saved to disk. When the user runs the game for the second time textures are read from the disk.DWORD wrote: Otherwise you could just make a texture with the text on it in Gimp or something. But you probably thought about that.
Marcin Jakubowski
jabber://myak@chrome.pl
jabber://myak@chrome.pl
-
DWORD
- OGRE Retired Moderator

- Posts: 1365
- Joined: Tue Sep 07, 2004 12:43 pm
- Location: Aalborg, Denmark
I see your point, and of course it's good to keep down the download size, so I really like your idea. Just keep in mind that Ogre's binaries already take up around 5 MB (unpacked). I just made a quick test: 200 textures with large text (512x64x32bit PNG) uses around 1 MB (unpacked). Of course it's probably easier to generate the text automatically, instead of manually 'painting' 200 textures, though, but it takes more code.myak wrote:Yeah, I thought about that. But including 200 textures would dramatically increase download size. What I want is when user runs the game for the first time textures are generated and saved to disk. When the user runs the game for the second time textures are read from the disk.
-
myak
- Halfling
- Posts: 40
- Joined: Fri May 23, 2003 10:46 pm
- Location: Warsaw, Poland
Hmm.. you're right! It uses 1MBDWORD wrote:I just made a quick test: 200 textures with large text (512x64x32bit PNG) uses around 1 MB (unpacked). Of course it's probably easier to generate the text automatically, instead of manually 'painting' 200 textures, though, but it takes more code.
But it would be nice to know how to do it anyway.
I just got another idea. If it was possible to get Image or even raw uchar* from Texture (I haven't found the way to do it yet) I could blit glyphs from the texture created by font to my texture.
Marcin Jakubowski
jabber://myak@chrome.pl
jabber://myak@chrome.pl
-
sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67