#include float kvadrat(char *s) { char *c; glPushMatrix(); glTranslatef(0.0, 0.0, 1.0); glNormal3f(0.0, 0.0, 1.0); glRectf(-1.0, -1.0, 1.0, 1.0); glTranslatef(-0.8, 0.0, 0.01); glDisable(GL_LIGHTING); glScalef(0.003, 0.003, 0.003); glColor3f(1.0, 0.0, 0.0); for(c=s; *c; c++) { glutStrokeCharacter(GLUT_STROKE_ROMAN, *c); } glEnable(GL_LIGHTING); glPopMatrix(); } void display() { float mat[4]={0.9, 0.6, 0.3, 1.0}; glClear(GL_COLOR_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT); glPushMatrix(); glRotatef(30.0, 1.0, 0.0, 0.0); glRotatef(30.0, 0.0, 1.0, 0.0); glScalef(0.5, 0.5, 0.5); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat); kvadrat("Spredaj"); glRotatef(90.0, 0.0, 1.0, 0.0); kvadrat("Desno"); glRotatef(90.0, 0.0, 1.0, 0.0); kvadrat("Zadaj"); glRotatef(90.0, 0.0, 1.0, 0.0); kvadrat("Levo"); glRotatef(90.0, 1.0, 0.0, 0.0); kvadrat("Spodaj"); glRotatef(180.0, 1.0, 0.0, 0.0); kvadrat("Zgoraj"); glPopMatrix(); glFlush(); } void reshape (int w, int h) { double l; l = 1; glViewport (0, 0, w, h); glMatrixMode (GL_PROJECTION); glLoadIdentity(); glOrtho(-l, l, -l, l, -l, l); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE|GLUT_DEPTH); glutCreateWindow("C GLUT program"); glutDisplayFunc(display); glutReshapeFunc(reshape); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glClearColor(1.0, 1.0, 1.0, 1.0); glutMainLoop(); return 0; }