Guest User

Untitled

a guest
Jan 22nd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. #include <GL\glut.h>
  2. #include <math.h>
  3.  
  4. double height = 600;
  5. double width = 600;
  6. const double DEG2RAD = 3.14159265/180;
  7.  
  8. void drawCircle2(double x, double y,double r)
  9. {
  10. glBegin(GL_POLYGON);
  11.  
  12. for (int i=0; i < 360; i++)
  13. {
  14. double deg = i*DEG2RAD;
  15. glVertex2d(cos(deg)*r+x,sin(deg)*r+y);
  16. }
  17.  
  18. glEnd();
  19. }
  20. /*
  21. void drawCircle(double x, double y, double r) {
  22. double xx1,yy1;
  23. glBegin(GL_LINES);
  24. for (double i = 0; i < 180; i+=2*eps)
  25. {
  26. xx1 = r * cos((double)i) + x;
  27. yy1 = r * sin((double)i) + y;
  28. glVertex3d(xx1,yy1,0);
  29.  
  30. xx1= r * cos(i + eps) + x;
  31. yy1 = r * sin(i + eps) + y;
  32. glVertex3d(xx1,yy1,0);
  33. }
  34. glEnd();
  35. }
  36. */
  37. void Draw() {
  38. glClear(GL_COLOR_BUFFER_BIT);
  39. glColor3f(1.0, 1.0, 1.0);
  40.  
  41. glEnable(GL_LINE_SMOOTH);
  42. glEnable(GL_BLEND);
  43. glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
  44. glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
  45.  
  46.  
  47. drawCircle2(200,200,100);
  48. glBegin(GL_LINES);
  49. glVertex2d(0, 0);
  50. glVertex2d(600, 300);
  51. glEnd();
  52. glFlush();
  53. }
  54.  
  55. void Initialize() {
  56. glClearColor(0.0, 0.0, 0.0, 0.0);
  57. glMatrixMode(GL_PROJECTION);
  58. glLoadIdentity();
  59. glOrtho(0.0, width, 0.0, height, -1.0, 1.0);
  60. }
  61.  
  62. int main(int iArgc, char** cppArgv) {
  63. glutInit(&iArgc, cppArgv);
  64. glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  65. glutInitWindowSize(width, height);
  66. glutInitWindowPosition(200, 200);
  67. glutCreateWindow("Example");
  68. Initialize();
  69. glutDisplayFunc(Draw);
  70. glutMainLoop();
  71. return 0;
  72. }
Add Comment
Please, Sign In to add comment