Jump to content
  • Advertisement

Archived

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

oni_viper

help with text

This topic is 5751 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
Advertisement
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
i plan on moving to dx8 eventually. maybe after this program is finished.

you code worked daerax, thank you. it flashes though. is there a way to fix that?

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
let me know if you find it grasshopa, i can''t find it. until then i''ll stick with the GDI and eventually upgrade to the bitmapped font.

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!