Sign in to follow this  

problem with drawing text

This topic is 4831 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 4831 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this