Skip to content

Instantly share code, notes, and snippets.

@epitron
Last active March 18, 2016 20:21
Show Gist options
  • Save epitron/bbce18c7225e952dc18f to your computer and use it in GitHub Desktop.
Save epitron/bbce18c7225e952dc18f to your computer and use it in GitHub Desktop.
int font_style = GLUT_BITMAP_HELVETICA_12;
void setfont(char* name, int size)
{
font_style = GLUT_BITMAP_HELVETICA_10;
if (strcmp(name, "helvetica") == 0) {
if (size == 12)
font_style = GLUT_BITMAP_HELVETICA_12;
else if (size == 18)
font_style = GLUT_BITMAP_HELVETICA_18;
} else if (strcmp(name, "times roman") == 0) {
font_style = GLUT_BITMAP_TIMES_ROMAN_10;
if (size == 24)
font_style = GLUT_BITMAP_TIMES_ROMAN_24;
} else if (strcmp(name, "8x13") == 0) {
font_style = GLUT_BITMAP_8_BY_13;
} else if (strcmp(name, "9x15") == 0) {
font_style = GLUT_BITMAP_9_BY_15;
}
}
void drawstr(float x, float y, float 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(font_style, *s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment