Possible Duplicate:
how to rotate this openGl code…
below is my code and it work fine.. i draw 5 ring in this.
#include <GL/glut.h>
#include <math.h>
static void redraw(void);
#define PI 3.14159265
#define EDGES 90
#define factor 10
void display (void)
{
glClearColor(1.0,1.0,1.0,0.0);
glMatrixMode (GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
//ring1
glPushMatrix();
glColor3f (0.0, 0.0 ,1.0);
glTranslatef(-30.0,10.0,-100.0);
redraw();
glutSwapBuffers();
glPopMatrix();
//ring2
glPushMatrix();
glColor3f (0.0, 0.0, 0.0);
glTranslatef(-8.0,10.0,-100.0);
redraw();
glutSwapBuffers();
glPopMatrix();
//ring3
glPushMatrix();
glColor3f (1.0, 0.0 ,0.0);
glTranslatef(14.0,10.0,-100.0);
redraw();
glutSwapBuffers();
glPopMatrix();
//ring4
glPushMatrix();
glColor3f (1.0, 1.0, 0.0);
glTranslatef(-19.0,-2.0,-100.0);
redraw();
glutSwapBuffers();
glPopMatrix();
//ring5
glPushMatrix();
glColor3f (0.0, 1.0, 0.0);
glTranslatef(4.0,-2.0,-100.0);
redraw();
glutSwapBuffers();
glPopMatrix();
}
static void redraw(void)
{
for (int i = 0; i < EDGES; i++)
{
glBegin(GL_LINE_LOOP);
glVertex2f(factor*cos((2*PI*i)/EDGES),factor*sin((2*PI*i)/EDGES));
glVertex2f(factor*cos((2*PI*(i+1))/EDGES),factor*sin((2*PI*(i+1))/EDGES));
glEnd();
}
}
int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowPosition(100,100);
glutInitWindowSize(110*3, 110*3);
glutCreateWindow("draw circle");
glPointSize(3);
glShadeModel (GL_FLAT);
glutDisplayFunc(display);
glMatrixMode(GL_PROJECTION);
gluPerspective(45,1.0,10.0,200.0);
glMatrixMode(GL_MODELVIEW);
glutMainLoop();
return 0;
}
so i want to rotate all of this circle.. how can i do??