Advertisement

GLUT and text

Started by July 19, 2000 07:24 AM
2 comments, last by Ched45 24 years, 4 months ago
Are there any GLUT functions to print text on screen? Just simple bitmap fonts etc? Thanx --Ched-- chris@ched45.com
--Ched--chris@ched45.com

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
Advertisement
Example program 9 on my site does this if you''re too lazy to cut and paste out of IE

Paul Groves
pauls opengl page
paul's opengl message board
Paul Grovespauls opengl page
Sorry, never saw your program 9 there.....lol.....Thanx

--Ched--
chris@ched45.com
--Ched--chris@ched45.com

This topic is closed to new replies.

Advertisement