Jump to content
  • Advertisement


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


GLUT and text

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Are there any GLUT functions to print text on screen? Just simple bitmap fonts etc? Thanx --Ched-- chris@ched45.com

Share this post

Link to post
Share on other sites

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.


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!