madzik4113

GRAFIKA zajecia2 RYSUNEK3

Mar 19th, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 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.  
  61. void Display()
  62. {
  63.  
  64. glClearColor(0,0,0,0);
  65. glClear(GL_COLOR_BUFFER_BIT);
  66.  
  67. //elipsa(0.8,0.1,0.6,0.4,0);
  68. rysunek3(0.3,0.1);
  69.  
  70. glFlush();
  71. glutSwapBuffers();
  72. }
  73.  
  74. int _tmain(int argc, char* argv[])
  75. {
  76. glutInit( &argc, argv);
  77. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
  78. glutInitWindowPosition(190,100);
  79. glutInitWindowSize(600 ,600);
  80. glutCreateWindow("lekcja2");
  81. glutDisplayFunc(Display);
  82. glMatrixMode(GL_PROJECTION);
  83. glutMainLoop();
  84. return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment