Rendering text without D3DX

Started by
2 comments, last by Norman Barrows 10 years, 4 months ago

Hi,

I'm trying to figure out how to render text to a D3D9 scene without using D3DXFont or any other extensions. Unfortunately, all of the googleverse examples seem to rely on that. What would be a good strategy for doing so?

I thought about rendering to a texture with DrawText, but that seems a little clunky. Not sure if there is something better.

Advertisement

Here is src example for bitmap font rendering from old ati radeon shadow map demo in attachment.

The basic process that you need to use is:

1. In an offline tool generate a texture which holds every character you need from the font, along with some metadata to tell you where each character is in the texture. You may also want other details like kerning pair data if the font is not monospaced. The texture can be single channel - D3DFMT_A8 for example as you can apply a colour at runtime. GetGlyphOutline(..., GGO_GRAY8_BITMAP, ...) will extract the data from a Windows font. A quick search should also find tools that will do this step for you.

2. At runtime go through the string building up a vertex buffer one character at at time, and then render it. This is essentially the same process as drawing a bunch of sprites from a sprite sheet. You'll also need special case handling of whitespace characters, and you'll probably need to handle word wrapping.

i discovered that d3dxfonts are SLOOOOW! so i implemented my own fonts using d3dx sprites. works great, runs fast.

i also use the font textures to texture 3d quads to make 3d text in the game world.

this is all done using dx9 fixed function pipeline.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement