Jump to content
  • Advertisement
Sign in to follow this  
Benjamin GD

Direct3D 9 text is coming out nasty and jagged

This topic is 2915 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

My font class:
class font
{
private:
ID3DXFont *my_font;

public:
void create(LPCSTR p_fontname, uint p_fontsize, uint p_bold, bool p_italic)
{
uint weight;
if (p_bold)
weight = 1000;
else
weight = FW_NORMAL;

D3DXCreateFont(device,MulDiv(p_fontsize,GetDeviceCaps(hdc,LOGPIXELSY),72),0,weight,0,p_italic,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,ANTIALIASED_QUALITY,DEFAULT_PITCH | FF_DONTCARE,p_fontname,&my_font);
}

void draw(LPCTSTR p_text, int p_x, int p_y, D3DXCOLOR p_color)
{
RECT rect = {p_x,p_y,0,0};
my_font->DrawTextA(NULL,p_text,-1,&rect,DT_TOP | DT_LEFT | DT_NOCLIP,p_color);
}
};


It looks extremely ugly on my screen with skipped lines and things like that. I have bought some Direct3D 9 games and the text doesn't look like this...

What do you think is wrong?

Share this post


Link to post
Share on other sites
Advertisement
Well, first of all, most published games probably don't use the ID3DXFont interface and roll out their own font routines.

Secondly, could you provide a screenshot or something? Would be easier to suggest what is wrong if we can actually see the result.

Share this post


Link to post
Share on other sites
Screenshot: http://www.upurload.com/files/b3163cfca5ed1fe842d5139e185ec9c6.png
How do I make this image show in the post? Can I use HTML or is it a weird form of BB code?

"most published games probably don't use the ID3DXFont interface"

What do they do then?

[Edited by - Benjamin GD on October 1, 2010 9:50:42 PM]

Share this post


Link to post
Share on other sites
Quote:
How do I make this image show in the post?

Take a look at the faq (upper-right-hand corner of this page).



Click on EDIT for my post and take a look at the format.

Are you drawing the text before or after you render the triangle?

EDIT: If you want to scare yourself about D3DXSPRITE and D3DXFONT, take a look at Evil Steve's article.

Share this post


Link to post
Share on other sites
Create a texture atlas offline (Photoshop, GIMP, perhaps a custom tool) that contains all your glyphs (and polish it appropriately), then use it in-game with a textured quad per character (batching, caching, etc as necessary).

Share this post


Link to post
Share on other sites
I'm not sure how relevant EvilSteve's article is anymore, Buckeye.

I know there have been many performance enhancements in ID3DXSprite/Font over the years, and at least one really big one. I'm rather certain that he was looking through an older version, especially if that was written in 2006.

Share this post


Link to post
Share on other sites
Could I possibly load font characters into an array of bitmaps or something? I don't actually know how to do this, but I want to know. I don't want to go without text in my game.


Edit: I mean font files themselves, it would be much easier for the people who use my engine to be able to choose default fonts, rather than get an artist to draw each letter...

[Edited by - Benjamin GD on October 1, 2010 10:24:26 PM]

Share this post


Link to post
Share on other sites
Make sure your back-buffer has the same size as the window. If you set the size of the back-buffer when creating your window, use AdjustWindowRectEx to make sure the actual client-area of the window is the same size. When you create a window the size you specify includes borders. If your back-buffer doesn't match your window size, it could make your image look wrong and miss pixels.

Share this post


Link to post
Share on other sites
Quote:
Original post by Benjamin GD
Edit: I mean font files themselves, it would be much easier for the people who use my engine to be able to choose default fonts, rather than get an artist to draw each letter...


You could base your engine's font system on the files produced by BMFont and instruct users to use this with whatever fonts they want.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!