# How to draw 3d text

This topic is 3317 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello all, I want to draw x, y and z axis labels in my surface plot. I can draw these labels using the glut library. But the problem is that when the plot is rotated the labels are not getting rotated. I know the reason that these labels are drawn in 2d. So thats why I want to draw 3d text so that the labels can also be rotated along with the plot. Thanks for your help, Regards, Srinu

##### Share on other sites
You could position your labels in 3D by specifying x,y,z coordinates (use your existing labels that you render in 2D). To make sure that they are facing in the correct direction so that they are readable, you want to billboard them: http://www.lighthouse3d.com/opengl/billboarding/

When you billboard an object you make sure that it is always facing the camera.

##### Share on other sites
Hi mmakrzem,
Thanks for your reply. I tied billboarding but it did not come useful to my requirement.
Actually What my exact requirement is that - I have a 3d plot and 3 axes (x, y and z). The divisions on these axes are drawn using glut. But when the plot is rotated the text divisions are not. I think glut draws text in 2d format. If it is 3d text then the divisions are also get rotated. So, basically I need the divisions should also get rotated along with the plot.

~Srinu

##### Share on other sites
You can obtain the 2D positions of the 3D objects, and draw the text at that position, using gluProject. Example:
GLdouble modelViewMatrix[16];GLdouble projMatrix[16];GLint viewport[4];GLdouble winx, winy, winz;glGetDoublev(GL_MODELVIEW_MATRIX, modelViewMatrix);glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);glGetIntegerv(GL_VIEWPORT, viewport);GLdouble winx, winy, winz;gluProject(	x3d,	y3d,	z3d,	modelViewMatrix,	projMatrix,	viewport,	&winx,	&winy,	&winz);drawTextAt(winx, winy);`

EDIT: Not sure what you want exactly, do you want the text _position_ to be rotated to correctly align with the 3D point, or do you want the actual text to be rotated, so that the text is a 3D object that you can move around and see from different directions?

##### Share on other sites
Hi Erik,
I am able to draw the text using the method you said. The text drawn in this way can be rotated? But I am not able to rotate the text.

TO all,
I am explaining my requirement once again with the image. Please look at the image at the following location.

I drawn the plot and axes same as in the above image. In this image the divisions or markings on the axes (0.0, 0.1, 0.2, 0.3, 0.4, etc....) can be rotated. Whereas in my image these can not be.
Simply, my requirement is that How to draw text which can be rotated? That is the actual text to be rotated, so that the text is a 3D object that we can move around and see from different directions.

Thanks,
Srinu

[Edited by - srinivaz111 on August 24, 2009 4:16:42 AM]

##### Share on other sites
Can anyone please tell me a solution to do this

~Srinu

##### Share on other sites
The easiest is probably to have your numbers in a texture, and draw them as textured quads along the axis.
There is also 3D fonts, check the following tutorial: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=14.

##### Share on other sites
But Nehe is only Windows !!

There is an easy to use library for rendering 3D text in OpenGL, FTGL:
http://sourceforge.net/projects/ftgl/

It supports texture fonts, vector fonts and 3D polygonal fonts. MIT license.
Requires FreeType.

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 12
• 12
• 9
• 14
• 10
• ### Forum Statistics

• Total Topics
632655
• Total Posts
3007670
• ### Who's Online (See full list)

There are no registered users currently online

×