Jump to content
  • Advertisement
Sign in to follow this  
Crazyfool

Writing text in Dx9(c++)

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

Howdy, I know how to write text, but so far I only know how to write it to SCREEN coordinates, and not to world coordinates. Is there a way it can be drawn to world coordinates similar to normal textures? Or is my best bet to just find the position it WOULD be relative to the person by finding the distance from the center and such?

Share this post


Link to post
Share on other sites
Advertisement
You have two options really:

1) Render the text as you are probably doing it now, with ID3DXFont, but render it to an offscreen render target and then texture a quad that lies somewhere in your world.

2) Create a mesh of text using, D3DXCreateText(), i believe it is.

Share this post


Link to post
Share on other sites
Awesome, thank you very much - and I am going to be attempting number 1 first, because I am just in need of some simple font usage.

Edit: is there a term that sums up what I should be looking for? I am trying a combination of words, but it seems must of it is coming up using sprites rather than textures.

Edit2: I realized I will be using sprites to keep the perspective always visible to the user. Leaving edit1 for completeness.

Share this post


Link to post
Share on other sites
Ok, so I am going to render the text to a sprite and then draw the sprite in the appropriate position that way if a player moves around, the text stays in the same spot.

Anywho, before I attempt this, I am trying to figure out the best road to take. I use textures (not sprites) for pretty much everything but the GUI, so I figure I am going to have to create a new sprite, draw the text, then add it to a collection of other text related sprites, and include them in the render() routine.

Does this sound like a plausible layout?

Share this post


Link to post
Share on other sites
Well first of all can you briefly describe what you are trying to do? What will the text be for? Are you trying to place the name of a player over their heads, for example? Like online FPSs do?

Share this post


Link to post
Share on other sites
Quote:
Original post by Crazyfool
Ok, so I am going to render the text to a sprite and then draw the sprite in the appropriate position that way if a player moves around, the text stays in the same spot.


The term you are looking for is called billboarding, seems like you know what you need to do but I thought you might want a new keyword to search for some tips :) I'm sure theres some billboarding samples in with the DXSDK too.

Share this post


Link to post
Share on other sites
after a bit of searching and playing around with it, it seems I am unaware how to draw sprites in world space (i.e., when I draw a texture, its in a different coordinate system than that of my mouse) and I can only get sprites to draw from mouse coordinates.

Is there an easy/painless way of drawing sprites in world space?

Share this post


Link to post
Share on other sites
Quote:
Original post by Dave
Well first of all can you briefly describe what you are trying to do? What will the text be for? Are you trying to place the name of a player over their heads, for example? Like online FPSs do?


Its for displaying information based on objects/entities in 3d space (like floating attack damage in World of Warcraft)

A player attacks a monster, the damage floats upwards over the monsters head.

Edit: Yes, the names above the head is similar in that sense, I will be wanting to do that as well.

Share this post


Link to post
Share on other sites
Try ID3DXSprite. It allows you to avoid a lot of boilerplate code. When you call Begin(), you should be able to pass in a flag specifying object space for your billboards. From there, you can generate a transform matrix and set it to ID3DXSprite, which will apply it to your sprite.

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!