Simple text
In this tutorial we’ll explain how to render text to the screen. This can be usefull to display debug information, but also to make a menu or console. What we’re going to try to do is render the all famous “hello world!” to our Truevision3D screen. For this, we created an all clean project again, to get rid of everything we’ve used so far, except for the TVEngine object.

What do we need?
- We need to tell DirectX that we want to draw text. You can do so by creating a texturefont. This can be done in the TVScreen2DText object.
How do we set this up?
- We need a TVScreen2DText object. This can be created in a normal way, you just create an instance of it, like you would with the tvengine.
- To create the texturefont, we call the following function:
This is not too hard to grasp. It creates an object with the name “our_font_name_string”, of the font called Times New Roman, with a 24pt size. The next couple of booleans are for: Bold, Underline, Italic, International and Clear Type Anti-Aliasing. The clear type anti-aliasing will provide us with more readable text. That’s basicly all there is to creating the texturefont.
How do we render this?
- To optimize the DirectX states (see: link) we can use:
Text2D.Action_EndText();
to define the beginning and end of the texture rendering.
- To make sure the text is in the middle of the screen, we need to know the height and width of the text. We can do that by calling:
It will put the result in W and H because they are references.
- Now we can draw the text by calling:
The parameters are: Text, x position, y position, int color and the texturefont id.
Things you can add/change yourself
- Play around a bit with the text, color, font etc. It’s not that exciting, but maybe you will find out things you didn’t know yet.