render 2d text at 3d position

Started by
5 comments, last by schue 19 years, 8 months ago
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?
Author Freeworld3Dhttp://www.freeworld3d.org
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.
as Raduprv saiz btw its called 'billboarding', should be lots of info on the net
Yes, but what if someone didn't want to use the billboarding and texture method.

Then how would you do it my way?
Author Freeworld3Dhttp://www.freeworld3d.org
You can't do it your way (properly, that is).
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?
Author Freeworld3Dhttp://www.freeworld3d.org
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.

This topic is closed to new replies.

Advertisement