Sign in to follow this  
soconne

render 2d text at 3d position

Recommended Posts

soconne    105
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
Raduprv    997
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
soconne    105
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
schue    176
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this