Archived

This topic is now archived and is closed to further replies.

Pellebert

Fastest way to draw text?

Recommended Posts

I need to write a GUI for one of my Direct3D applications, and I want to now the fastest (best) way to draw the text. Is it by using two triangles for each letter and draw them at the same time, or is it by just blitting the letters to the backbuffer?

Share this post


Link to post
Share on other sites
If you want your text to have translucency of any kind--either applied to entire characters or per-pixel translucency to preserve antialiasing in the character images--you''ll have to use the texture-mapped quad (or two triangles) method. Otherwise, you can just blit it to the back buffer. As for which is faster: it depends on the graphics hardware, so there is no single, constant answer. So, decide based upon what features you need.

Share this post


Link to post
Share on other sites
Doing a blit potentially stalls the 3D operations which tend to buffer up some way behind. It also won''t work on some older hardware!

Doing them as texture mapped quads is a good thing to do - as long as you aren''t issuing a single quad per draw call. Less than about 50 polygons per draw call is a *bad* thing to do.

Pack as many characters of your font into a single texture as possible on the hardware you''re running on - on newer hardware you should be able to fit a full large font on a single texture. Doing that allows you to use a single draw call to draw ALL the text you need on the screen.

Indexed primitives save 2 vertices per character - this is good.

Since the vertices will probably be different for each frame (assuming proportional font) make sure you use the correct dynamic vertex buffer locking scheme!

The indices won''t change for a screen full of indexed quads - may be an idea to create the indices/*static* index buffer once for a maximum number of characters then use the indices ranges passed to the draw call/SetIndices to control how many are used. May save bus activity, validity checking on Win2K/WinXP and other overhead - a good thing.

Using only the good things above, we had screens full of text on top of complete 3d scenes in Pac-Man:Adventures in Time running at a reasonable rate on S3 ViRGEs and Matrox Mystiques.

--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites