- #include <stdio.h>
- #include <GL/gl.h>
- #include <GL/glut.h>
- float x=0,y,x2,y2,m,i,j,p;
- int dx=0,dy=0,r,k,d;
- void display(void)
- {
- glClear (GL_COLOR_BUFFER_BIT);
- glEnd();
- //front wheel
- r=150;
- for(r=r; r>=140; r=r-10)
- {
- y=r;
- x=0;
- d = r/10;
- k = d%2;
- if(k==0)
- {
- glColor3f (1.0, 1.0, 1.0);
- glBegin(GL_POLYGON);
- }
- else{
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- }
- p=1-r;
- while((x<=y))
- {
- if(p<0)
- {
- x=x+1;
- y=y;
- p=p+(2*x)+1;
- }
- else
- {
- x=x+1;
- y=y-1;
- p=p+(2*x)+1-(2*y);
- }
- glVertex2f (x-300, y-300);
- glVertex2f (y-300, x-300);
- glVertex2f (-x-300, -y-300);
- glVertex2f (-x-300, y-300);
- glVertex2f (x-300, -y-300);
- glVertex2f (y-300, -x-300);
- glVertex2f (-y-300, -x-300);
- glVertex2f (-y-300, x-300);
- }
- glEnd();
- }
- //front wheel spikes
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_LINES);
- glVertex2f (-300, -450);
- glVertex2f (-300, -150);
- glVertex2f (-450, -300);
- glVertex2f (-150, -300);
- glVertex2f (-375, -225);
- glVertex2f (-225, -375);
- glVertex2f (-225, -225);
- glVertex2f (-375, -375);
- glEnd();
- //front mid point
- r=30;
- y=r;
- x=0;
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- p=1-r;
- while((x<=y))
- {
- if(p<0)
- {
- x=x+1;
- y=y;
- p=p+(2*x)+1;
- }
- else
- {
- x=x+1;
- y=y-1;
- p=p+(2*x)+1-(2*y);
- }
- glVertex2f (x-300, y-300);
- glVertex2f (y-300, x-300);
- glVertex2f (-x-300, -y-300);
- glVertex2f (-x-300, y-300);
- glVertex2f (x-300, -y-300);
- glVertex2f (y-300, -x-300);
- glVertex2f (-y-300, -x-300);
- glVertex2f (-y-300, x-300);
- }
- glEnd();
- //rear wheel
- r=150;
- for(r=r; r>=140; r=r-10)
- {
- y=r;
- x=0;
- d = r/10;
- k = d%2;
- if(k==0)
- {
- glColor3f (1.0, 1.0, 1.0);
- glBegin(GL_POLYGON);
- }
- else{
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- }
- p=1-r;
- while((x<=y))
- {
- if(p<0)
- {
- x=x+1;
- y=y;
- p=p+(2*x)+1;
- }
- else
- {
- x=x+1;
- y=y-1;
- p=p+(2*x)+1-(2*y);
- }
- glVertex2f (x+300, y-300);
- glVertex2f (y+300, x-300);
- glVertex2f (-x+300, -y-300);
- glVertex2f (-x+300, y-300);
- glVertex2f (x+300, -y-300);
- glVertex2f (y+300, -x-300);
- glVertex2f (-y+300, -x-300);
- glVertex2f (-y+300, x-300);
- }
- glEnd();
- }
- //rear wheel spikes
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_LINES);
- glVertex2f (300, -450);
- glVertex2f (300, -150);
- glVertex2f (450, -300);
- glVertex2f (150, -300);
- glVertex2f (375, -225);
- glVertex2f (225, -375);
- glVertex2f (225, -225);
- glVertex2f (375, -375);
- glEnd();
- //rear mid point
- r=30;
- y=r;
- x=0;
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- p=1-r;
- while((x<=y))
- {
- if(p<0)
- {
- x=x+1;
- y=y;
- p=p+(2*x)+1;
- }
- else
- {
- x=x+1;
- y=y-1;
- p=p+(2*x)+1-(2*y);
- }
- glVertex2f (x+300, y-300);
- glVertex2f (y+300, x-300);
- glVertex2f (-x+300, -y-300);
- glVertex2f (-x+300, y-300);
- glVertex2f (x+300, -y-300);
- glVertex2f (y+300, -x-300);
- glVertex2f (-y+300, -x-300);
- glVertex2f (-y+300, x-300);
- }
- glEnd();
- //front rod
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (-10, -300);
- glVertex2f (10, -300);
- glVertex2f (-140, 0);
- glVertex2f (-160, 0);
- glEnd();
- //seat rod
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (-10, -300);
- glVertex2f (10, -300);
- glVertex2f (235, 150);
- glVertex2f (215, 150);
- glEnd();
- //paddle
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (-10, -200);
- glVertex2f (10, -200);
- glVertex2f (10, -400);
- glVertex2f (-10, -400);
- glEnd();
- //upper part
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (-30, -200);
- glVertex2f (30, -200);
- glVertex2f (30, -180);
- glVertex2f (-30, -180);
- glEnd();
- //lower part
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (-30, -400);
- glVertex2f (30, -400);
- glVertex2f (30, -420);
- glVertex2f (-30, -420);
- glEnd();
- //chain
- r=60;
- for(r=r; r>=40; r=r-10)
- {
- y=r;
- x=0;
- d = r/10;
- k = d%2;
- if(k==0)
- {
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- }
- else{
- glColor3f (1.0, 1.0, 1.0);
- glBegin(GL_POLYGON);
- }
- p=1-r;
- while((x<=y))
- {
- if(p<0)
- {
- x=x+1;
- y=y;
- p=p+(2*x)+1;
- }
- else
- {
- x=x+1;
- y=y-1;
- p=p+(2*x)+1-(2*y);
- }
- glVertex2f (x, y-300);
- glVertex2f (y, x-300);
- glVertex2f (-x, -y-300);
- glVertex2f (-x, y-300);
- glVertex2f (x, -y-300);
- glVertex2f (y, -x-300);
- glVertex2f (-y, -x-300);
- glVertex2f (-y, x-300);
- }
- glEnd();
- }
- //back rod
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (310, -310);
- glVertex2f (290, -310);
- glVertex2f (140, 0);
- glVertex2f (160, 0);
- glEnd();
- //ground rod
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (300, -310);
- glVertex2f (300, -290);
- glVertex2f (55, -290);
- glVertex2f (55, -310);
- glEnd();
- //upper rod
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (140, 0);
- glVertex2f (160, -20);
- glVertex2f (-140, -20);
- glVertex2f (-160, 0);
- glEnd();
- //handle rod
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (-290, -300);
- glVertex2f (-310, -300);
- glVertex2f (-65, 180);
- glVertex2f (-45, 180);
- glEnd();
- //handle
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (-65, 180);
- glVertex2f (-45, 180);
- glVertex2f (-115, 230);
- glVertex2f (-135, 230);
- glEnd();
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (-115, 230);
- glVertex2f (-135, 230);
- glVertex2f (-100, 270);
- glVertex2f (-80, 270);
- glEnd();
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (-100, 270);
- glVertex2f (-100, 260);
- glVertex2f (-20, 260);
- glVertex2f (-20, 270);
- glEnd();
- //seat
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (235, 150);
- glVertex2f (215, 150);
- glVertex2f (145, 170);
- glVertex2f (165, 170);
- glEnd();
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (145, 170);
- glVertex2f (165, 170);
- glVertex2f (185, 180);
- glVertex2f (165, 180);
- glEnd();
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (165, 180);
- glVertex2f (165, 175);
- glVertex2f (295, 175);
- glVertex2f (295, 180);
- glEnd();
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (235, 150);
- glVertex2f (215, 150);
- glVertex2f (275, 160);
- glVertex2f (285, 160);
- glEnd();
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (275, 160);
- glVertex2f (285, 160);
- glVertex2f (300, 170);
- glVertex2f (295, 170);
- glEnd();
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (300, 170);
- glVertex2f (295, 170);
- glVertex2f (295, 180);
- glVertex2f (285, 180);
- glEnd();
- //basket
- glColor3f (0.0, 0.0, 0.0);
- glBegin(GL_POLYGON);
- glVertex2f (-85, 180);
- glVertex2f (-250, 180);
- glVertex2f (-190, 0);
- glVertex2f (-145, 0);
- glEnd();
- glColor3f (1.0, 1.0, 1.0);
- glBegin(GL_LINES);
- glVertex2f (-168, 180);
- glVertex2f (-168, 0);
- glVertex2f (-127, 180);
- glVertex2f (-150, 0);
- glVertex2f (-209, 180);
- glVertex2f (-180, 0);
- glEnd();
- glFlush ();
- }
- void init (void)
- {
- glClearColor (1.0, 1.0, 1.0, 1.0);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluOrtho2D(-600.0, 600.0, -600.0, 600.0);
- }
- int main(int argc, char** argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
- glutInitWindowSize (600, 600);
- glutInitWindowPosition (100, 100);
- glutCreateWindow ("171-15-9263");
- init ();
- glutDisplayFunc(display);
- glutMainLoop();
- return 0;
- }