Jump to content
  • Advertisement
Sign in to follow this  
soconne

render 2d text at 3d position

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

I'm trying to render the letter 'y' above the y axis but its not staying exactly at the top of the axis. When I move the camera around it swerves away from the axis, sometimes a lot. Here's my code so far gluProject(0, 1, 0, modelview, projection, viewport, &winX, &winY, &winZ); winX /= double(viewport_width); winY /= double(viewport_height); glColor3f(1,1,1); glRasterPos2d(winX, winY); glPrint("Y"); And glPrint is the same code from NeHe's tutorial on system fonts. Anyway, shouldn't this work?

Share this post


Link to post
Share on other sites
Advertisement
The way to properly do it is like this:
Create a fonts texture (if you don't have one)
Assign a quad to each character
Draw the quads that have your letters for the text you want to display in the 3D world at the desired position, but remember to turn the quads that way so they will face the camera.

Share this post


Link to post
Share on other sites
Yes, but what if someone didn't want to use the billboarding and texture method.

Then how would you do it my way?

Share this post


Link to post
Share on other sites
Well let's just pretend that I want to stray from the norm and do something different :-) So then my question remains, anybody know what is wrong with my code above?

Share this post


Link to post
Share on other sites
Than i would guess you need to project the 3d-coordinate of where your letter 'y' should be in 3d-dpace to the 2d-space of your ortho. Pretty much to opposite way of how you translate mouse-clicks from 2d into 3d space.

Personally this would be the last thing I would do, as its way too complicated, but if you need to do things "different", it might be your wtg.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!