render 2d text at 3d position
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?
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.
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.
Yes, but what if someone didn't want to use the billboarding and texture method.
Then how would you do it my way?
Then how would you do it my way?
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?
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.
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
Popular Topics
Advertisement