Jump to content
  • Advertisement


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


Drawing 2D-Text into 3D-Window

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

Hi. I got a simple 3D-Scene running in windowed mode of DX 8.1. I''d like to display the frame rate unsing the interface "ID3DXFont", which has a DrawText() -function. My call looks like this: m_pFont->DrawText("FPS:", 4, &textRect, DT_CENTER, D3DCOLOR_RGBA(0,255,255,127)); where m_pFont is the interfacepointer created with D3DXCreateFont(m_pd3dDevice, g_hFont, &m_pFont); and g_hFont is a Handle to a Font created with Win32-Api function CreateFont(...); All functions work(at least they don''t return error values) but there is no text displayed(not in my textRect or anywhere). Does anyone know what I''m doing wrong or if there is another easy way of diplaying 2d-Text without using GDI?

Share this post

Link to post
Share on other sites
Your problem most likley is that you are not setting up a rectangle for the text to go into. All you have to do is change the DrawText code to look like this:

m_pFont->DrawText("FPS:", -1, &textRect, DT_CENTER, 0));
m_pFont->DrawText("FPS:", -1, &textRect, DT_CENTER, D3DCOLOR_RGBA(0,255,255,127));

Your problem _should_ be solved now, the reason I call the first DrawText with 0 in the color area is because the ID3DXFont needs to know how much room is required to draw the text. If this does not work post back here, or email me at:

Good Luck, hope this solves your problem

Share this post

Link to post
Share on other sites
Thanks for the reply, but that didn''t do it.
Still the same problem.
When i run the app in debug-mode, i get a lot of DX-warnings about redundant SetRenderState and SetTextureStageState calls when i call the Draw()-func of D3DXFont in my renderfunction but the text is not displayed...

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!