Jump to content
  • Advertisement
Sign in to follow this  
sirob

Rendering Text in a Chat Window

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

Okay, so I'd like to make a small chat window for my game (for multiplayer mode, really). So, I'm gonna make a small box and render text into it with the D3DXFONT library. Now, heres my problem -- How do I know how many rows a line of text is going to take? That is, if it's too long I'll have to split it to two rows, or maybe more. I could render all the text as one Draw call, which would automagically word wrap, but then I won't be able to select which rows I'm showing the user... Is there any way to calculate this, cause I've been looking everywhere. Also, I plan to render the chat box to a texture whenever it changes, then use the sprite interface to render the texture every frame. This is a good idea, right?

Share this post


Link to post
Share on other sites
Advertisement
The docs say that the return value of DrawText is the height of the text.
Quote:
Return Value

If the function succeeds, the return value is the height of the text in logical units. If DT_VCENTER or DT_BOTTOM is specified, the return value is the offset from pRect->top to the bottom of the drawn text.

If the function fails, the return value is zero.


You may want to "verify" the heights/positions of your text objects using the DT_CALCRECT setting.

Hope that helps somewhat.

Share this post


Link to post
Share on other sites
Sign in to follow this  

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