sohag_cse

Lab Task - 04 (182-15-2164-PC-A)

Oct 23rd, 2021
1,053
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <GL/glut.h>
  2. #include <stdio.h>
  3. #include <GL/gl.h>
  4.  
  5. void init(void)
  6. {
  7.     glClearColor(0.0,0.0,0.0,0.0);
  8.     glMatrixMode(GL_PROJECTION);
  9.     glLoadIdentity();
  10.     glOrtho(0.0, 750.0, 0.0, 650.0, -1.0, 1.0);
  11. }
  12. void Draw()
  13. {
  14.     glClear(GL_COLOR_BUFFER_BIT);
  15.     glColor3f( 0.1,0.6, 0.4);
  16.     int a=380, b=190, c=570, d=342;
  17.     int dy=d-b;
  18.     int dx=c-a;
  19.     int dif=2*dy-2*dx;
  20.     int p0=2*dy-dx;
  21.     int p=p0;
  22.     int x=a, y=b;
  23.     glBegin(GL_POINTS);
  24.     glVertex2d(x,y);
  25.     while(1)
  26.     {
  27.         if(p>=0)
  28.         {
  29.             x++;
  30.             y++;
  31.             p=p+dif;
  32.         }
  33.         else
  34.         {
  35.             x++;
  36.             p=p+2*dy;
  37.         }
  38.         glVertex2d(x,y);
  39.         if(x==c && y==d)
  40.             break;
  41.     }
  42.     glEnd();
  43.     glFlush();
  44.     glutSwapBuffers();
  45. }
  46. int main(int argc,char **argv)
  47. {
  48.     glutInit(&argc,argv);
  49.     glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE );
  50.     glutInitWindowPosition(0,0);
  51.     glutInitWindowSize(550,550);
  52.     glutCreateWindow("Sohag Raha 182-15-2164");
  53.     init();
  54.     glutDisplayFunc(Draw);
  55.     glutMainLoop();
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment