Вот код:
#!/usr/bin/perl
use OpenGL;
($width, $height) = (1280,800);
glpOpenWindow;
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LEQUAL);
glDepthRange(0, 1);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearColor(0, 0, 0, 0);
glClearDepth(1);
$alpha = 0;
$beta = 0;
while (1) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
#glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glPushMatrix();
glRotatef(90, 1, 0, 1);
glRotatef($alpha, 0, 1, 0);
glBegin(GL_QUADS);
glColor3f(0, 0.6, 0);
glVertex3f(-0.5, -0.5, -0.5);
glVertex3f(0.5, -0.5, -0.5);
glVertex3f(0.5, -0.5, 0.5);
glVertex3f(-0.5, -0.5, 0.5);
glEnd();
glBegin(GL_TRIANGLES);
glColor3f(0, 0.7, 0);
glVertex3f(-0.5, -0.5, -0.5);
glVertex3f(0, 0.5, 0);
glVertex3f(0.5, -0.5, -0.5);
glColor3f(1, 0.8, 0);
glVertex3f(0.5, -0.5, -0.5);
glVertex3f(0, 0.5, 0);
glVertex3f(0.5, -0.5, 0.5);
glColor3f(0, 0.9, 1);
glVertex3f(0.5, -0.5, 0.5);
glVertex3f(0, 0.5, 0);
glVertex3f(-0.5, -0.5, 0.5);
glColor3f(1, 1, 1);
glVertex3f(-0.5, -0.5, 0.5);
glVertex3f(0, 0.5, 0);
glVertex3f(-0.5, -0.5, -0.5);
glEnd();
glPopMatrix();
#glPushMatrix();
#glRotatef(90, 1, 0, -1);
#glRotatef($beta, 0, 1, 0);
#glBegin(GL_TRIANGLES);
#glColor3f(0.7, 0, 0);
#glVertex3f(-0.5, -0.5, -0.5);
#glVertex3f(0, 0.5, 0);
#glVertex3f(0.5, -0.5, -0.5);
#glColor3f(0.8, 0, 0);
#glVertex3f(0.5, -0.5, -0.5);
#glVertex3f(0, 0.5, 0);
#glVertex3f(0.5, -0.5, 0.5);
#glColor3f(0.9, 0, 0);
#glVertex3f(0.5, -0.5, 0.5);
#glVertex3f(0, 0.5, 0);
#glVertex3f(-0.5, -0.5, 0.5);
#glColor3f(1, 0, 0);
#glVertex3f(-0.5, -0.5, 0.5);
#glVertex3f(0, 0.5, 0);
#glVertex3f(-0.5, -0.5, -0.5);
#glEnd();
#glPopMatrix();
glpFlush();
$alpha = $alpha + 0.5;
$beta = $beta - 1;
}
glpMainLoop;