Jump to content
  • Advertisement


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


CD3DFont vs. ???? AAAaaaaarrrrgggghhh

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

ok, so i need to draw some text in my game... at first i saw a DrawText() routine in the D3DX8 lib exaplained in a way that looked like i could implement it in about 6 lines... this falied miserably. next i saw the CD3DFont method... im sure this creates extra overhead and is slow (it calls the GDI right?). the only other method i can see is creating a texuture with the entire ASCII (im using that not unicode) set on it. i did that but can''t figure out how to make a custom vertex buffer with an unknown amount of verts (i tried creating one like a dynamic array which, once again, didnt work). so here i sit very frustrated asking for help drawing text... what is the best way to do it in DX8 and PLEASE FOR GODS SAKE point me to information on how to do it (why did microcrap do such a bad job documenting text in DX8??) ok im gonna quit now before i have a hairy conniption. thanks for help if you can give it Brett Lynnes cheez_keeper@hotmail.com

Share this post

Link to post
Share on other sites
The CD3DFont is a quick and dirty implementation of somethiong you are going to have to do anyway.

The class uses the GDI initially to print text into a bitmap.

This is then used as a texture when you 'draw' the text on the screen. Because of this it is pretty fast, but you can't change style or point size once it is created.

I use it for simple stuff, like a frame per second counter and debug messages.

Warning. If you use a large point font, you get artifacts in the letter 'i'.

There is a font interface in DX8 that does all sorts of fancy stuff, but this is slow as it uses the GDI EVERY time to create a generate the text befare if blits it to the screen.

You need two types of text. 'In game' text where speed is essential, and transition text, such as for menus, options, pre-game briefings, etc..., here speed is not necassary.

What I used to do ( a million years ago before the PC Junior), was to generate each letter as a sprite and then blt it on to the screen. Guess what. I effectively do the same thing today. Create a texture of each letter (with metrics, i.e. width), and then


You get the picture.

the vertex information in your Vertex Buffer contains transformed vertex coordinates, that way you can supply absolute screen coordinates.

When specifying you Flexible Vertex Format use D3DFX_XYZRHW.


Edited by - DeltaVee on February 15, 2001 11:02:00 PM

Share this post

Link to post
Share on other sites
i have my own texture implemented... but i have a small problem... i don''t know how big to create the VB... i can''t seem to create it dynamically VertBuf = new DIRECT3DVERTEXBUFFER8 VertBuf[num]; will create it fine... but even after the memcpy the information seems to dissappear (i think when i leave the function the dynamic array holing the info deletes itsef... hmmm maybe if i draw in the routine too....

but if that doesnt work i have 3 other options (thanks delV) i can create a really HUGE vb to hold as many letters and possible in a line (ugly), i can call DrawPrimitive once per letter (i think calling it 25 times at 4 verts each might be slower than just calling it once on 100 verts though...??), or i can use C3D3Font. the way delV explained it, it shouldn''t slow my fr down too much right?

thanks for the reply... i guess i got some stuff to try out.

Brett Lynnes
"To err is human. to FUBAR you need a computer."

Share this post

Link to post
Share on other sites
This is the way I do. I get about 90 fps when I draw a text buffer containing 500 elements in my 3D game right now:

I write all letters I need to use in Visul Studio with black background. Then I make copy of the screen and crop the font image to size 128x128 with my paint program. This image is then converted to a transparent DDS file with DirectX Texture Tool.

Then I create a texture of that picture with D3DXCreateTextureFromFile and use it like a regular sprite map. I register all bitmap positions for every letter in a vector in a class. Then when I want to display some text I dynamicly create a vertex buffer and fill in the right texture position and screen position for every letter.

Dont forget to make a release call of the VB object before every new call to CreateVertexBuffer...

Gandalf the Black

Share this post

Link to post
Share on other sites

  • 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!