Guest User

Untitled

a guest
May 20th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <GL/glut.h>
  3. #include <stdlib.h>
  4. #include <math.h>
  5.  
  6.  
  7. #define t 640
  8. #define sz 4
  9. #define l 20
  10.  
  11. void init(void) {
  12. glClearColor(0.0, 0.8, 0.8, 1.0);
  13. glOrtho(0, 256, 0, 256, -1, 1);
  14. }
  15.  
  16. void drawFilledCircle(GLfloat x, GLfloat y, GLfloat radius){
  17. int i;
  18. int triangleAmount = 20;
  19.  
  20. GLfloat twicePi = 2.0f * 3.1415f;
  21.  
  22. glBegin(GL_TRIANGLE_FAN);
  23. glVertex2f(x, y); // center of circle
  24. for(i = 0; i <= triangleAmount;i++) {
  25. glVertex2f(
  26. x + (radius * cos(i * twicePi / triangleAmount)),
  27. y + (radius * sin(i * twicePi / triangleAmount))
  28. );
  29. }
  30. glEnd();
  31. }
  32.  
  33. void display(void) {
  34. glClear(GL_COLOR_BUFFER_BIT);
  35.  
  36. glColor3f(1.0,0.0,0.0);
  37.  
  38. glBegin(GL_POLYGON);
  39. glVertex2i(10, 10);
  40. glVertex2i(10, 100);
  41. glVertex2i(80, 100);
  42. glVertex2i(80, 10);
  43. glEnd();
  44.  
  45. glColor3f(0.0,1.0,0.0);
  46.  
  47. glBegin(GL_POLYGON);
  48. glVertex2i(30, 10);
  49. glVertex2i(30, 60);
  50. glVertex2i(60, 60);
  51. glVertex2i(60, 10);
  52. glEnd();
  53.  
  54. glColor3f(0.0,0.0,1.0);
  55.  
  56. glBegin(GL_POLYGON);
  57. glVertex2i(10, 100);
  58. glVertex2i(45, 160);
  59. glVertex2i(80, 100);
  60. glEnd();
  61.  
  62. glColor3f(1.0,0.0,1.0);
  63.  
  64. glBegin(GL_POLYGON);
  65. glVertex2i(80, 100);
  66. glVertex2i(45, 160);
  67. glVertex2i(170, 160);
  68. glVertex2i(200, 100);
  69. glEnd();
  70.  
  71. glColor3f(0.0,1.0,1.0);
  72.  
  73. glBegin(GL_POLYGON);
  74. glVertex2i(80, 10);
  75. glVertex2i(200, 10);
  76. glVertex2i(200, 100);
  77. glVertex2i(80, 100);
  78. glEnd();
  79.  
  80. glColor3f(0.0,0.0,0.0);
  81.  
  82. glBegin(GL_POLYGON);
  83. glVertex2i(120, 40);
  84. glVertex2i(120, 80);
  85. glVertex2i(170, 80);
  86. glVertex2i(170, 40);
  87. glEnd();
  88.  
  89. glColor3f(1.0,1.0,0.0);
  90.  
  91. drawFilledCircle(200.0, 200.0, 25.0);
  92.  
  93. glutSwapBuffers();
  94. }
  95. int main(int argc, char** argv){
  96. glutInit(&argc, argv);
  97. glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
  98. glutInitWindowSize(t, t);
  99. glutInitWindowPosition(100,100);
  100. glutCreateWindow("House");
  101. init();
  102. glutDisplayFunc(display);
  103. glutMainLoop();
  104. return 0;
  105. }
Add Comment
Please, Sign In to add comment