Archived

This topic is now archived and is closed to further replies.

Ched45

GLUT and text

Recommended Posts


Try this:

GLvoid *fontStyle = GLUT_BITMAP_TIMES_ROMAN_10;

void DrawGLUTString(GLuint x, GLuint y, char *text)
{
char *s;

// Move to the required raster position that you want text to appear
glRasterPos2i(x, y);

// Display each character from string - you can only do one at a time
for (s = text; *s; s++)
glutBitmapCharacter(fontStyle, *s);
}

Obviously, you''ll have to set fontStyle to whatever you need (take a look at the glut header file ''glut.h'')

Also, this would be better improved by passing stdarg params instead of a straight ''char *text''. This would then allow you to pass parameters as you would to printf() - do a lookup on the va_start/vsprintf/va_end functions.

--Andy
http://opengl.koolhost.com

Share this post


Link to post
Share on other sites