SHARE
TWEET

JY

a guest Feb 15th, 2020 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<windows.h>
  2. #include<iostream.h>
  3. #include<stdio.h>
  4. #include<stdlib.h>
  5. #include<string.h>
  6. #include<math.h>
  7. #include<GL/gl.h>
  8. #include<GL/glu.h>
  9. #include<GL/glut.h>
  10.  
  11.  
  12. //const int screenWidth = 640*2;
  13. //const int screenHeight = 480*2;
  14. //GLdouble A,B,C,D; // values for scaling and shifting
  15.  
  16. void myInit(void)
  17. {
  18.   glClearColor(1.0, 1.0, 1.0, 0.0);  //background color is white
  19.   glColor3f(0.0f, 0.0f, 0.0f);  //drawing color is black
  20.   glPointSize(4.0); //a dot is 2 by 2 pixels
  21.   //glLineWidth(4.0); //a line is 4 times thicker
  22.  
  23.  
  24.   //initialize view (simple orthographic projection)
  25.   glMatrixMode(GL_PROJECTION);
  26.   glLoadIdentity();
  27.   //glOrtho(-1.0,1.0,-1.0, 1.0, -1.0, 1.0);
  28.  
  29.  // A = screenWidth/4.0; //Set values for scaling and shifting
  30.  // B= 0.0;
  31.  // C=D=screenHeight/2.0;
  32.  
  33.   //set the viewing coordinates
  34.   gluOrtho2D(0.0, 640.0, 0.0, 480.0);
  35. }
  36.  
  37. void myDisplay(void)
  38. {
  39.   glClear(GL_COLOR_BUFFER_BIT);   //clear the screen
  40.   // glRecti(10,10,150,60); //draw a rectangle with background color
  41.  
  42.  
  43.   glPointSize(2.0);
  44.  
  45.   GLint h = 200,k = 200, x, y, r, d;
  46.  
  47.   y = r = 100;
  48.   d = 3 - 2*r;
  49.    
  50.   for(x=0; x<=y; x++)
  51.     {
  52.       glBegin(GL_POINTS);
  53.       {
  54.          
  55.     glVertex2i(x+h,y+k);
  56.     glVertex2i(x+h,k-y);
  57.     glVertex2i(y+h,x+k);
  58.     glVertex2i(y+h,k-x);
  59.     glVertex2i(-y+h,x+k);
  60.     glVertex2i(-y+h,k-x);
  61.     glVertex2i(-x+h,y+k);
  62.     glVertex2i(-x+h,k-y);
  63.  
  64.       }
  65.       glEnd();
  66.  
  67.       if(d<0)
  68.  
  69.           d = d + 4*x + 6;
  70.       else{
  71.  
  72.           d = d + 4*(x-y) + 10;
  73.           y--;
  74.       }
  75.     }
  76.  
  77.   glFlush(); //send all output to display
  78. }
  79.  
  80.  
  81. int  main(int argc, char** argv)
  82. {
  83.   glutInit(&argc, argv);  //initialize the toolkit
  84.   glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); //set the display mode
  85.   glutInitWindowSize(640,480);  //set window size
  86.   //set window position on screen
  87.   glutInitWindowPosition(100,150);  
  88.   //open the screen window and set the name
  89.   glutCreateWindow("My First Window");  
  90.  
  91.   //register the callback functions
  92.   glutDisplayFunc(myDisplay);
  93.  
  94.   myInit();
  95.   glutMainLoop();  //go into a perpetual loop
  96.  
  97. return 1;
  98.  
  99. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top