/* Fonts */ //Adapted from code by Nate Robins for tw GLvoid * TWFontStyle = GLUT_BITMAP_8_BY_13; void twSetFont(char* name, int size) { if (strcmp(name, "helvetica") == 0) { if (size == 12) TWFontStyle = GLUT_BITMAP_HELVETICA_12; else if (size == 18) TWFontStyle = GLUT_BITMAP_HELVETICA_18; else { twMessage(TW_FONTS,"Warning, no helvetica font at size %d, using 12\n",size); TWFontStyle = GLUT_BITMAP_HELVETICA_12; } } else if (strcmp(name, "times roman") == 0) { if (size == 10) TWFontStyle = GLUT_BITMAP_TIMES_ROMAN_10; else if (size == 24) TWFontStyle = GLUT_BITMAP_TIMES_ROMAN_24; else { twMessage(TW_FONTS,"Warning, no times roman font at size %d, using 10\n",size); TWFontStyle = GLUT_BITMAP_TIMES_ROMAN_10; } } else if (strcmp(name, "8x13") == 0) { TWFontStyle = GLUT_BITMAP_8_BY_13; } else if (strcmp(name, "9x15") == 0) { TWFontStyle = GLUT_BITMAP_9_BY_15; } else { twMessage(TW_FONTS,"Warning: no font matches %s; using default 8x13\n",name); TWFontStyle = GLUT_BITMAP_8_BY_13; } } void twDrawString(GLuint x, GLuint y, char* format, ...) { va_list args; char buffer[255], *s; va_start(args, format); vsprintf(buffer, format, args); va_end(args); glRasterPos2i(x, y); for (s = buffer; *s; s++) glutBitmapCharacter(TWFontStyle, *s); } void twDrawString(GLfloat x, GLfloat y, GLfloat z, char* format, ...) { va_list args; char buffer[255], *s; va_start(args, format); vsprintf(buffer, format, args); va_end(args); glRasterPos3f(x, y, z); for (s = buffer; *s; s++) glutBitmapCharacter(TWFontStyle, *s); }