#include<iostream.h> #include<GL/glut.h> #include<math.h> #include<stdlib.h> const double TWO_PI =6.2831853; GLsizei winWidth=400,winHeight=400; GLuint regHex; class screenPt { public: GLint x,y; }; static void init(void) { screenPt hexVertex,circCtr; GLdouble theta; GLint k; circCtr.x=winWidth/2; circCtr.y=winHeight/2; glClearColor(1.0,1.0,1.0,0.0); regHex=glGenLists(1); glNewList(regHex,GL_COMPILE); glColor3f(1.0,0.0,0.0); glBegin(GL_POLYGON); for(k=0;k<6;k++) { theta=TWO_PI*k/6.0;// hexVertex.x=circCtr.x+150*cos(theta); hexVertex.y=circCtr.y+150*sin(theta); glVertex2i(hexVertex.x,hexVertex.y); } glEnd(); glEndList(); } void regHexagon(void) { glClear(GL_COLOR_BUFFER_BIT); glCallList(regHex); glFlush(); } void winReshapeFcn(int newWidth,int newHeight) { glMatrixMode(GL_PROJECT