Tuesday 24 December 2013

OPENGL PROGRAM TO DRAW GINGER BEARD MAN

#include<GL/glut.h>
#include<stdlib.h>
#include<math.h>

void myInit()
{
     glClearColor(1.0,1.0,1.0,0.0);
     glColor3f(1.0,0.0,0.0);
     glPointSize(4.0);
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
     gluOrtho2D(0.0,640.0,0.0,480.0);
     }
    


      void myDisplay()
      {
           glClear(GL_COLOR_BUFFER_BIT);
           glColor3f(0.0,0.0,0.0);
           int m=40,l=3;
           unsigned long int i=0;
           int px=115,py=121;
           int qx=0,qy=0;
           glBegin(GL_POINTS);
           for(i=0;i<100000;i++)
           {
                         qx=m*(1+2*l)-py+abs(px-l*m);
                         qy=px;
                         glVertex2i(qx,qy);
                         px=qx;
                         py=qy;
                         }
                         glEnd();
                         glFlush();
                        
                         }   
         
          int main(int argc ,char **argv)
          {
               glutInit(&argc,argv);
               glutInitDisplayMode(GLUT_SINGLE| GLUT_RGB );
               glutInitWindowSize(640,480);
               //glutInitWindowPosition(200,200);
               glutCreateWindow("gingerbeard man");
               glutDisplayFunc(myDisplay);
               myInit();
               glutMainLoop();
               }


No comments:

Post a Comment