Advertisement
iamyeasin

Untitled

Dec 10th, 2019
598
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. #include<windows.h>
  2. #include <GL/glut.h>
  3. #include <GL/gl.h>
  4. #include <bits/stdc++.h>
  5.  
  6. using namespace std;
  7.  
  8. double x1,y11,x2,y2,delx,dely,delm,x,y,pk,r;
  9.  
  10. void display(void){
  11. // DDA Line Drawing
  12. glClear(GL_COLOR_BUFFER_BIT);
  13. glColor3f(1,0,0);
  14.  
  15. // x=x1,y=y11;
  16. // delx = x2-x1, dely=y2-y11;
  17. // delm = (dely/delx);
  18. //
  19. // if( abs(delm) <=1 ){
  20. // while(x < x2){
  21. // x++, y += delm;
  22. // glBegin(GL_POINTS);
  23. // glVertex2i(x,round(y));;
  24. // glEnd();
  25. // }
  26. // }
  27. // else{
  28. // while(y < y2 ){
  29. // y++ , x += (1/delm);
  30. // glBegin(GL_POINTS);
  31. // glVertex2i(round(x),y);
  32. // glEnd();
  33. // }
  34. //
  35. // }
  36.  
  37. /// circle line Drawing Algorithm
  38. // pk = 1-r;
  39. // x = 0, y= r;
  40. //
  41. // while( x <= y ){
  42. // glBegin(GL_POINTS);
  43. //
  44. // glVertex2i(x,y);
  45. // glVertex2i(x,-y);
  46. // glVertex2i(-x,-y);
  47. // glVertex2i(-x,y);
  48. //
  49. // glVertex2i(y,x);
  50. // glVertex2i(y,-x);
  51. // glVertex2i(-y,-x);
  52. // glVertex2i(-y,x);
  53. // glEnd();
  54. // x++;
  55. //
  56. // if( pk < 0 ){
  57. // pk += (2*x + 1);
  58. // }
  59. // else{
  60. // pk += ( (2*x)-(2*y) + 1 );
  61. // y--;
  62. // }
  63. //
  64. // }
  65.  
  66. /// Brasenhas algorithm
  67. // m = (y2-y11)/ (x2-x1);
  68. // y = y11,x = x1;
  69. //
  70. // if(m<=1){
  71. // while(x<x2){
  72. //
  73. // x=x+1;
  74. // if(pk > 0) pk= pk + (2*(dy-dx));
  75. // else pk=pk + 2*(dy);
  76. //
  77. // glBegin(GL_POINTS);
  78. // glVertex2f(x,y);
  79. // glEnd();
  80. // }
  81. //
  82. // }
  83.  
  84. float angle = 0;
  85.  
  86. const double t = glutGet(GLUT_ELAPSED_TIME) / 500.0; //retrieves simple GLUT state represented by integers.
  87. const double a = t*180.0;
  88.  
  89. glPushMatrix();
  90. glTranslated(0.0,0.0,-6);
  91. glRotated(0,1,0,0);
  92. glRotated(a,0,0,1);
  93. glutSolidCone(1,0.5,160,160);
  94.  
  95. glColor3d(1,0.5,0);
  96. glBegin(GL_POLYGON);
  97. glVertex3f(1.5, 1.0, -6);
  98. glVertex3f(5.0, 2.0, -6);
  99. glVertex3f(5.0, 3.0, -6);
  100. glVertex3f(0.0, 2.0, -6);
  101. glEnd();
  102.  
  103. glColor3d(0.5,0.5,1);
  104. glBegin(GL_POLYGON);
  105. glVertex3f(-1.5, -1.0, -6);
  106. glVertex3f(-5.0, -2.0, -6);
  107. glVertex3f(-5.0, -3.0, -6);
  108. glVertex3f(-0.0, -2.0, -6);
  109. glEnd();
  110.  
  111. glColor3d(0,1,1);
  112. glBegin(GL_POLYGON);
  113. glVertex3f(-1.0, 1.5, -6);
  114. glVertex3f(-2.0, 5.0, -6);
  115. glVertex3f(-3.0, 5.0, -6);
  116. glEnd();
  117.  
  118. glColor3d(1,0,1);
  119. glBegin(GL_POLYGON);
  120. glVertex3f(1.0, -1.5, -6);
  121. glVertex3f(2.0, -5.0, -6);
  122. glVertex3f(3.0, -5.0, -6);
  123. glVertex3f(2.0, 0, -6);
  124. glEnd();
  125.  
  126.  
  127.  
  128.  
  129.  
  130. glEnd();
  131. glPopMatrix();
  132.  
  133. glutPostRedisplay();
  134.  
  135.  
  136.  
  137.  
  138. glFlush();
  139. }
  140.  
  141. void init(void){
  142. glClearColor(1,1,1,5.0);
  143. glMatrixMode(GL_PROJECTION);
  144.  
  145. glLoadIdentity();
  146. glPointSize(5.0);
  147. glOrtho(-100,100,-100,100,-100,100) ;
  148.  
  149. }
  150.  
  151. int main(int argc, char **argv)
  152. {
  153. glutInit(&argc, argv);
  154. glutInitDisplayMode(GLUT_RED | GLUT_SINGLE );
  155. glutInitWindowSize(800,500);
  156. glutInitWindowPosition(100,100);
  157. glutCreateWindow("Testing ");
  158.  
  159. //cin >> r ;
  160.  
  161. init();
  162. glutDisplayFunc(display);
  163. glutMainLoop();
  164.  
  165. return 0;
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement