#include <windows.h>
#include <gl/gl.h>
#include <gl/glut.h>
float angle;
void display ()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-26.0f);
glRotatef(angle,1.0f,0.0f,0.0f);
float x,y;
for (x =-15.0f;x<15.0f;x+=3.0f)
{
for (y =-15.0f;y<15.0f;y+=3.0f)
{
glPushMatrix();
glTranslatef (x, y , 0);
glBegin (GL_QUADS);
glColor3f (1, 0, 0); glVertex2f ( 1, 1);
glColor3f (0, 1, 0); glVertex2f (-1, 1);
glColor3f (0, 0, 1); glVertex2f (-1,-1);
glColor3f (1, 1, 1); glVertex2f ( 1,-1);
glEnd ();
glPopMatrix ();
}
}
glLoadIdentity();
glTranslatef(0.0f,0.0f,-26.0f);
glRotatef(angle,0.0f,1.0f,0.0f);
for (x =-15.0f;x<15.0f;x+=3.0f)
{
for (y =-15.0f;y<15.0f;y+=3.0f)
{
glPushMatrix();
glTranslatef (x, y , 0);
glBegin (GL_QUADS);
glColor3f (1, 0, 0); glVertex2f ( 1, 1);
glColor3f (0, 1, 0); glVertex2f (-1, 1);
glColor3f (0, 0, 1); glVertex2f (-1,-1);
glColor3f (1, 1, 1); glVertex2f ( 1,-1);
glEnd ();
glPopMatrix ();
}
}
angle+=0.15f;
glutSwapBuffers( );
}
void reshape ( int w, int h )
{
glViewport ( 0, 0, w, h );
glMatrixMode ( GL_PROJECTION );
glLoadIdentity ( );
gluPerspective ( 80, ( float ) w / ( float ) h, 1.0, 1000.0 );
glMatrixMode ( GL_MODELVIEW );
glLoadIdentity ( );
}
void keyboard ( unsigned char key, int x, int y )
{
if (key == 27) exit(0);
}
int main ( int argc, char** argv )
{
glutInit( &argc, argv );
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE );
glutInitWindowSize (500, 500 );
glutCreateWindow ( "planes" );
glutFullScreen();
glutDisplayFunc( display );
glutReshapeFunc( reshape );
glutKeyboardFunc( keyboard );
glutIdleFunc( display );
glutMainLoop();
}
|