Reputation: 1854
I used the following code to display some simple text:
void output(GLfloat x, GLfloat y, char *format,...)
{
va_list args;
char buffer[200], *p;
va_start(args, format);
vsprintf(buffer, format, args);
va_end(args);
glPushMatrix();
glLoadIdentity();
glTranslatef(x, y, -1000);
for (p = buffer; *p; p++)
glutStrokeCharacter(GLUT_STROKE_ROMAN, *p);
glPopMatrix();
}
But I don't know how could I change/specify the size of the text?
Or is there a better way to do this?
Upvotes: 1
Views: 863
Reputation: 473417
First, please never use vsprintf. And I don't mean to start using iostream or something; I mean to use vsnprintf. That way, you don't walk off the end of your character array.
Second, you should be using glutStrokeString
to draw a string.
Most importantly, since the GLUT text rendering code uses the current matrix, if you want to change the size of the text, you can just drop a scale matrix into the matrix stack with glScalef
. This probably only works with stroked fonts though, which you are using.
Upvotes: 2