madzik4113

GRAFIKA zajecia2 RYSUNEK4

Mar 19th, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <GL\glew.h>
  3. #include <GLFW/glfw3.h>
  4. #include <glm/glm/glm.hpp>
  5. #include <GL/glut.h>
  6. #include <stdlib.h>
  7. #include <cmath>
  8. #include <iostream>
  9. using namespace std;
  10. #define PI 3.14159265
  11.  
  12. void elipsa(float r, float kat,float mx, float my, bool poziomo)
  13. {
  14. float rozmiar=360/kat;
  15. float przyrost = kat;
  16.  
  17. if(poziomo==true)
  18. {
  19. swap(mx,my);
  20. }
  21.  
  22. glBegin(GL_LINES);
  23. glColor3f(1,0,0);
  24. for(int i=0;i<rozmiar;i++)
  25. {
  26. //glVertex3f(mx*r*cos(kat),my*r*sin(kat),0);
  27. kat+=przyrost;
  28. glVertex3f(mx*r*cos(kat),my*r*sin(kat),0);
  29.  
  30.  
  31.  
  32.  
  33.  
  34. }
  35. glEnd();
  36.  
  37. }
  38.  
  39. void rysunek3(float r,float kat)
  40. {
  41. float mx=0.3;
  42. float my=0.6;
  43. int ile=6;
  44.  
  45. for(int i=0;i<ile;i++)
  46. {
  47. elipsa(r,kat,mx,my,0);
  48. elipsa(r,kat,mx,my,1);
  49. mx+=0.3;
  50. my+=0.3;
  51.  
  52. }
  53. elipsa(r,kat,(ile+1)*0.3,(ile+1)*0.3,0);
  54.  
  55.  
  56.  
  57.  
  58.  
  59. }
  60. void rysunek4(int zwoje,float size)
  61. {
  62. float kat=0;
  63. float przyrost=0.05;
  64. glColor3f(1,0,0);
  65. glBegin(GL_LINES);
  66. do
  67. {
  68. glVertex3f(kat/360*size*cos(kat),kat/360*size*sin(kat),0);
  69. kat+=przyrost;
  70. glVertex3f(kat/360*size*cos(kat),kat/360*size*sin(kat),0);
  71. }
  72. while(kat<2*zwoje*PI);
  73.  
  74.  
  75. glEnd();
  76.  
  77. }
  78.  
  79. void Display()
  80. {
  81.  
  82. glClearColor(0,0,0,0);
  83. glClear(GL_COLOR_BUFFER_BIT);
  84.  
  85. //elipsa(0.8,0.1,0.6,0.4,0);
  86. ///rysunek3(0.3,0.1);
  87. rysunek4(6,5);
  88.  
  89. glFlush();
  90. glutSwapBuffers();
  91. }
  92.  
  93. int _tmain(int argc, char* argv[])
  94. {
  95. glutInit( &argc, argv);
  96. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
  97. glutInitWindowPosition(190,100);
  98. glutInitWindowSize(600 ,600);
  99. glutCreateWindow("lekcja2");
  100. glutDisplayFunc(Display);
  101. glMatrixMode(GL_PROJECTION);
  102. glutMainLoop();
  103. return 0;
  104. }
Advertisement
Add Comment
Please, Sign In to add comment