First try copying the text down first:
#include <GL/glut.h> double aspect_ratio = 0; void reshape(int w, int h) { aspect_ratio = (double)w / (double)h; glViewport(0, 0, w, h); } void output(GLfloat x, GLfloat y, char* text) { glPushMatrix(); glTranslatef(x, y, 0); glScalef(1/152.38, 1/152.38, 1/152.38); for( char* p = text; *p; p++) { glutStrokeCharacter(GLUT_STROKE_ROMAN, *p); } glPopMatrix(); } void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-10*aspect_ratio, 10*aspect_ratio, -10, 10, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glColor3ub(255,0,0); output(0,0,"hello"); glutSwapBuffers(); } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE); glutInitWindowSize(640,480); glutCreateWindow("Text"); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMainLoop(); return 0; }
If you read the documentation you provided, you will find that GLUT_STROKE_ROMAN is large by default, about 152 units.
If I remember correctly the default projection matrices and model matrices, which you depending on giving you a viewport that covers only (-1, -1) - (1,1).
source share