Archived

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

help with text

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

can anybody show me a link or some sample code to get text to show up with directx. i''ve looked on the internet with now success and the sample code here on gamedev doesn''t work, it just knocks me out of the program. any help is appreciated. thanks in advance.

Share this post


Link to post
Share on other sites
It would probably be best to move on to DX8+ sooner than later. With DX9 right around the corner, learning DX7 is going to actually teach you less and less. There was a decent change in overall structure from DX7 to DX8 and you will have much relearning to do if you concentrate on 7. You can do 2D quite happily (albeit differently) in DX8. Unless you have a very good reason to stay with DX7 (you specifically need/want to support older hardware), there is no reason not to move up.

Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces"

Share this post


Link to post
Share on other sites
Be complete, learn Directdraw. Then learn how Direct3D does it in DX8. If I had my way I''d tell you to learn how it was done in the days of DOS (ohh the memories, Ralph Brown''s Interrupt list comes to mind).

Anyway, the easiest way is to use the GDI.

HDC hdc1;
char texts[100];

sprintf(texts, "Blah : %d",blah);

lpddsprimary->Restore();
lpddsprimary->GetDC(&hdc1);

TextOut(hdc1, 0 , 0, texts, strlen(texts));

lpddsprimary->ReleaseDC(hdc1);

Thats all. You could make your own font engine but I''m certain thats not what you''re looking for.

Share this post


Link to post
Share on other sites
Yeah, Don''t use GDI .

I''ve found that the most efficient way to display text in DirectX (DirectDraw and D3D) is use bitmapped fonts. That is, create a simple bitmap image that contains all the letters you want to display, then create a simple manager to draw each one like a sprite.

There is also a very well done class CD3DFont (I believe this is the name) that''s included in the DX SDK. It uses normal, windows fonts and creates bitmapped fonts out of them. You may want to check it out.

Kevin

-----------------------------
kevin@mayday-anime.com
http://www.mayday-anime.com

Share this post


Link to post
Share on other sites
If you have the DX 8.1 SDK, the classes are located in the files in d3dfont.h and d3dfont.cpp contained in the SDK_ROOT\samples\Multimedia\Common\src and include directories respectively. Take a look at those.

Kevin

-----------------------------
kevin@mayday-anime.com
http://www.mayday-anime.com

Share this post


Link to post
Share on other sites
Direct3D 8 has support for GDI-like fonts build in, i think its
called D3DXFONT or something similiar
check out the webpage below, thats
where I learned how to use it.

http://www.drunkenhyena.com/docs/d3d8/d3d_lesson13.phtml

That in conjunction with the info on MSDN is a pretty comprehensive, although you should have at least a basic understanding of Direct3D first.

Theres also CD3DFont as mentioned by grasshopa55, but I''ve never used it.

-Paul-

Share this post


Link to post
Share on other sites
Posting in a new thread since this one is long. sorry for my post.

Much greatness is achieved thru perseverance and faith.



[edited by - Paladin__ on November 21, 2002 10:11:51 AM]

Share this post


Link to post
Share on other sites