🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

GLUT and text

Started by
2 comments, last by Ched45 23 years, 11 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
Advertisement

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
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