PDA

View Full Version : How to draw text with GLUT?



akira32
03-17-2011, 02:24 AM
How to draw text with GLUT?

I reference a sample code as below website:
glutStrokeCharacter (http://pyopengl.sourceforge.net/documentation/manual/glutStrokeCharacter.3GLUT.html)

But I cannot see any text on my screen. I put a part of my code as below. My window is create by SDL.
Please someone help me to solve this problem rendering a text in OpenGL!


void output(GLfloat x, GLfloat y, char *text)
{
char *p;

glPushMatrix();
glTranslatef(x, y, 0);
for (p = text; *p; p++)
glutStrokeCharacter(GLUT_STROKE_ROMAN, *p);
glPopMatrix();
}


glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
glLineWidth(2.0);

glColor3f( 1.0f, 1.0f, 1.0f);
output(0, 0, "This is antialiased.");
glColor3f( 1.0f, 1.0f, 1.0f);