icatalin

tema 3.3 [GRAFICA]

Mar 18th, 2020
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. #include <windows.h>
  2. #include <gl/freeglut.h>
  3. #include <cmath>
  4. #include <iostream>
  5.  
  6.  
  7. void init(void)  // initializare fereastra de vizualizare
  8. {
  9.     glClearColor(1.0, 1.0, 1.0, 0.0); // precizeaza culoarea de fond a ferestrei de vizualizare
  10.  
  11.     glMatrixMode(GL_PROJECTION);  // se precizeaza este vorba de o reprezentare 2D, realizata prin proiectie ortogonala
  12.     gluOrtho2D(0.0, 800, 0.0, 800.0); // sunt indicate coordonatele extreme ale ferestrei de vizualizare
  13. }
  14.  
  15.  
  16. class Punct
  17. {
  18. public:
  19.     float x, y, z;
  20.  
  21.     Punct(int xx, int yy, int zz)
  22.     {
  23.         x = xx;
  24.         y = yy;
  25.         z = zz;
  26.     }
  27.  
  28.     Punct()
  29.     {
  30.         x = y = z = 0;
  31.     }
  32. };
  33.  
  34. Punct produsVectorial(Punct A, Punct B)
  35. {
  36.     Punct prod;
  37.     prod.x = A.y * B.z - A.z * B.y;
  38.     prod.y = A.z * B.x - A.x * B.z;
  39.     prod.z = A.x * B.y - A.y * B.x;
  40.  
  41.     return prod;
  42. }
  43.  
  44. void desen()
  45. {
  46.     Punct A(1, 1, 0), B(0, 0, 1);
  47.     Punct prod = produsVectorial(A, B);
  48.     std::cout <<"Produsul vectorial intre A si B este: "<< prod.x << " " << prod.y << " " << prod.z<<"\n\n";
  49.  
  50.     glFlush();
  51. }
  52.  
  53. void main(int argc, char** argv)
  54. {
  55.     glutInit(&argc, argv);
  56.     glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  57.     glutInitWindowPosition(50, 50);
  58.     glutInitWindowSize(800, 800);
  59.     glutCreateWindow("Poligoane in context 3D. Fata si spatele unui poligon");
  60.  
  61.     init();
  62.     glClear(GL_COLOR_BUFFER_BIT);
  63.     glutDisplayFunc(desen);
  64.     glutMainLoop();
  65. }
Advertisement
Add Comment
Please, Sign In to add comment