problem with drawing text

Started by
3 comments, last by manusha 19 years, 7 months ago
hi, i'm using DrawTextA method of D3DXFONT interface to draw some 2D text on the screen. however the drawn text is not clear and does not represent the corrcet size. when text size is small ( 8 pts height), i cant even read it. is there any alternative way of doing this. i saw a sample called 3DText in SDK but cant understand much of the coding since i'm new to directX. so please help me if u can. thank you
Advertisement
If you scale or otherwise do stuff to the sprite with text on it, the text will likely get aliased or otherwise mangled.

I'm just rendering in XYZRHW mode, and it works fine for me. 8pt is still a bit tiny and difficult to read. 12pt is much better imo. [at 1024x768]
D3DXFONT is one way to go and it should work. Its also very easy to get working text with that. Sorry I cant get you an code cause im not on my computer at the moment(been a while since I used this). If you want this method try lgoogling for some class.
Edit: With D3DXFONT as keyword I found a perfect and very easy tutorial as first match: http://www.riaz.de/tutorials/d3d09/d3d09.html

My current engine however uses another approach which is more general.
Just load a texture containing all the letters and symbols.
Then fill a vertexbuffer with squares, one for each letter. Each square will need to have the right texture coords to capture its letter.
Then switch to a 2d Direct3D mode and draw the squares one after another for each character in the given string.
If you use some standard for the texture then you can just index the letters by using the numerical value of each character minus some constant.
Th drawback is that you have a fixed size but some good speed.
If you want different sizes you could also have one square and dynamically alter that for each draw call.

-CProgrammer
I do something similar also.First I grab the bitmaps images (of letters) and store them is a file (as an linear array) along with the char which the image represents.Then when they are needed they are loaded into a class which returns the pointer to the array which holds the data.

Storing the char which is represented by the images makes the things sligthly easier but you will have to make each char manually.Once ;).

Btw check out this link to Make a Font Engine

Helps?
______________________________________________________________________________________________________
[AirBash.com]
hi all ,
i think i got the idea. since i'm new to diirectX , i need to first figure out how to use textures to draw text. currntly i'm
following some MSDN tutorials on that, but they are too advanced for me. so if u know any tutorial on this for beginners, it would be great.
thank u very much for all ideas. if anyone knows some more information on this plz let me know.

This topic is closed to new replies.

Advertisement