draw text to an image or a texture?
Posted: Thu May 15, 2008 10:57 pm
Hi there,
in order to avoid drawing a text every frame to the screen again and again I want to draw text to a texture and display this texture instead. So I have to redraw that texture only if the text changes.
But I have no idea how to draw text to an image or a texture with Irrlicht.
I suppose I have to ...
#1. create an image in memory,
#2. draw the text to it
#3. convert the image to a texture (or copy the image's pixel-buffer to the texture's pixel/image-buffer) and
#4. tell an already displayed quad or billboard to use this texture or tell the system that the texture has been changed.
Problems:
regarding #1:
No CImage- or CTexture class found.
regarding #2:
Today I draw text with font->draw() to the screen, where font is of type gui::IGUIFont*. But this "draw" method has no parameter to indicate a target image buffer. So I suppose it is set somewhere in this strange guienvironment-thingy, but I realy have no clue how that works. Maybe it's in the video driver? (Thats the problem with a class library in c++: things that belong to each other are never easy to find using the API-docs ...)
However: Found an IImage and an ITexture. But while looking into the API docs, both seem to have no pixel- or graphicsbuffer to hold the actual image. Well, they are just interfaces. So where is the image buffer?
regarding #3:
absolutely no idea. I thought there should be a constructor to create a texture from an image ... wouldn't that be a likely approach?
regarding #4:
Well, I hoped I could find something like it in the 13.RenderToTexture example, but no, I didn't.
Any hint to solve any of my four problems is most welcome.
Ayman
in order to avoid drawing a text every frame to the screen again and again I want to draw text to a texture and display this texture instead. So I have to redraw that texture only if the text changes.
But I have no idea how to draw text to an image or a texture with Irrlicht.
I suppose I have to ...
#1. create an image in memory,
#2. draw the text to it
#3. convert the image to a texture (or copy the image's pixel-buffer to the texture's pixel/image-buffer) and
#4. tell an already displayed quad or billboard to use this texture or tell the system that the texture has been changed.
Problems:
regarding #1:
No CImage- or CTexture class found.
regarding #2:
Today I draw text with font->draw() to the screen, where font is of type gui::IGUIFont*. But this "draw" method has no parameter to indicate a target image buffer. So I suppose it is set somewhere in this strange guienvironment-thingy, but I realy have no clue how that works. Maybe it's in the video driver? (Thats the problem with a class library in c++: things that belong to each other are never easy to find using the API-docs ...)
However: Found an IImage and an ITexture. But while looking into the API docs, both seem to have no pixel- or graphicsbuffer to hold the actual image. Well, they are just interfaces. So where is the image buffer?
regarding #3:
absolutely no idea. I thought there should be a constructor to create a texture from an image ... wouldn't that be a likely approach?
regarding #4:
Well, I hoped I could find something like it in the 13.RenderToTexture example, but no, I didn't.
Any hint to solve any of my four problems is most welcome.
Ayman