/* Displays "Hello World" using OGL - Open Graphics Library http://en.wikipedia.org/wiki/OpenGL http://www.lighthouse3d.com/opengl/glut/index.php?1 (tutorial w/ Glut) http://freeglut.sourceforge.net/ (Glut updated) */ #include #define font GLUT_BITMAP_HELVETICA_18 #define tx "Hello World !" void text(void) /* write text in color buffer */ { char *p, tex[] = tx; p = tex; glColor3d(1.0, 1.0, 0.0); glRasterPos2d(-.5, 0.); while(*p) glutBitmapCharacter(font, *p++); } void display() /* display text */ { glClear(GL_COLOR_BUFFER_BIT); text(); glFlush(); } void reshape(int width, int height) /* when window is moved or reshaped */ { glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1, 1, -1, 1, -1, 1); glMatrixMode(GL_MODELVIEW); display(); } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowPosition(50, 50); glutInitWindowSize(500, 500); glutCreateWindow("Hello World OpenGL"); glClearColor(0,0,0,0); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMainLoop(); return 0; }