Direct3D 9 text is coming out nasty and jagged

Started by
11 comments, last by Evil Steve 13 years, 6 months ago
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?
If Microsoft's had a taste, it would taste like a Styrofoam cup. That's how nasty and artificialishly ugly they make their code look... C# is a disgusting language.
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.
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]
If Microsoft's had a taste, it would taste like a Styrofoam cup. That's how nasty and artificialishly ugly they make their code look... C# is a disgusting language.
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.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Okay, so what are my other options?
If Microsoft's had a taste, it would taste like a Styrofoam cup. That's how nasty and artificialishly ugly they make their code look... C# is a disgusting language.
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).
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.
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]
If Microsoft's had a taste, it would taste like a Styrofoam cup. That's how nasty and artificialishly ugly they make their code look... C# is a disgusting language.
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.
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.

This topic is closed to new replies.

Advertisement