Displaying text with DirectX

Started by
14 comments, last by roloenusa 15 years, 9 months ago
i meant outside of the direct loop and in the WM_PAINT message or somthing.

why would o involve copying the backbuffer to system memory?

Advertisement
Quote:Original post by wforl
i meant outside of the direct loop and in the WM_PAINT message or somthing.

why would o involve copying the backbuffer to system memory?
If you write the text to the backbuffer (Using GetDC() on it to get a HDC), the backbuffer would need to be copied to system memory to write to it.

If you try writing to the target window's HDC directly then you'll likely run into all sorts of synchronisation issues in full screen mode (Although windowed might work).
Most game code I've had the pleasure of looking at had a whole system of UI elements implemented.

For text. I've seen text areas being just a quad somewhere that had a font member.
The font member contained bitmap images that were taken from a "font strip" image created by an artist. The font member was responsible for calculating smaller quads for each character, figuring out dimensions and spacing, extracting them from the font strip, controlling alpha, etc.

Usually all this was loaded up during intialization from some xml file containing font defintions, text areas, and actual placement of elements.

I gave it a shot in DX9, but never really finished. My project is now in conversion from 9 to 10, but feel free to look at it if you like

Look for EngineX on ftp://christopherpisz.is-a-geek.com/pub/programming/Projects/
and see if you can find the "font" class.

It might be good for gleaming some ideas.

[Edited by - brekehan on July 14, 2008 4:42:55 PM]
Thank you so much for the responses.

This has been a lot more information than i expected. I think i personally will go with the library in DirectX since it seems to be a good play for a noobie to get started.

I have another question related to this same issue. I have seen two different libraries thrown around: D3DXFont and ID3DXFont. For what i understand ID3DXFont supports international fonts. Besides that, is there any real difference between them? Older threads on the forums indicate that ID3DXFont is a lot slower. Have things changed since 2003? Is there a real advantage to using D3DXFont over ID3DXFont?

Thank you again!
Quote:Original post by roloenusa
I have another question related to this same issue. I have seen two different libraries thrown around: D3DXFont and ID3DXFont. For what i understand ID3DXFont supports international fonts. Besides that, is there any real difference between them? Older threads on the forums indicate that ID3DXFont is a lot slower. Have things changed since 2003? Is there a real advantage to using D3DXFont over ID3DXFont?
I assume all the posts in this thread really mean ID3DXFont, which used to be a bit slow but is much faster now (And has been for a few years). I'd recommend going with that until you find you're having performance problems, and you've profiled and found ID3DXFont to be the bottleneck.

D3DFont (Not D3DXFont) existed in an older version of the SDK; I seem to recall it created a 3D mesh for the text, like the Windows 3D text OpenGL screensaver.
Great!

Thank you so much again! You guys are awesome

This topic is closed to new replies.

Advertisement