Pipeline graphique
 Tout Structures de données Espaces de nommage Fichiers Fonctions Variables Définitions de type Énumérations Valeurs énumérées Macros
Pipeline.cpp
Aller à la documentation de ce fichier.
1 #include "Pipeline.h"
2 
14 Pipeline::Pipeline(int sx,int sy,bool dothread)
15 {
16  sizeX = sx;
17  sizeY = sy;
18  Display = new rgb[sizeX*sizeY];
19  zBuffer = new float[sizeX*sizeY];
20 
21  unsigned long taille = sizeX*sizeY;
22  for(unsigned long i = 0; i < taille; i++)
23  {
24  zBuffer[i] = 50000;
25  }
26 
27  DoCull = false;
28  DoClip = true;
29  DoCCW = false;
30  viewPoint = false;
31  viewMaille = false;
32  viewRemplisage = true;
33  Dothread = dothread;
34  if(Dothread)
35  {
36  for(int i = 0 ; i < sx; i++ )
37  {
38  m_mutex.push_back(new std::mutex());
39  }
40  }
41  nbMAXthread = 4;
42 }
48 {
49  delete[] Display;
50  delete[] zBuffer;
51  for(unsigned int i = 0; i < m_mutex.size(); i++)
52  {
53  delete m_mutex.at(i);
54  }
55 }
56 
57 void Pipeline::threadRemplissage(Pipeline *monpipeline,Sommet *somettransformer,FaceteEcran *facette )
58 {
59  if(monpipeline->viewPoint)
60  {
61  OperationPixel(coord2d(facette->som1.x,facette->som1.y),monpipeline,somettransformer,facette);
62  OperationPixel(coord2d(facette->som2.x,facette->som2.y),monpipeline,somettransformer,facette);
63  OperationPixel(coord2d(facette->som3.x,facette->som3.y),monpipeline,somettransformer,facette);
64  }
65 
66 
67  // on trace les contour
68  if(monpipeline->viewMaille)
69  {
70  drawLine(somettransformer,monpipeline,facette);
71  }
72 
73 
74  if(monpipeline->viewRemplisage)
75  {
76  Remplissage(somettransformer,monpipeline,facette);
77  }
78 
79  //On desaloue se qu'on a mis en memoire pour les thread
80  delete[] somettransformer;
81  delete facette;
82 }
83 
84 
90 void Pipeline::setViewPoint(bool var)
91 {
92  viewPoint = var;
93 }
100 {
101  viewMaille = var;
102 }
103 
111 {
112  viewRemplisage = var;
113 }
114 
120 void Pipeline::setCulling(bool var)
121 {
122  this->DoCull = var;
123 }
129 void Pipeline::setCliping(bool var)
130 {
131  this->DoClip = var;
132 }
133 
140 {
141  Sommet *somettransformer = new Sommet[3];
142 
143 
144  for(unsigned int i = 0; i < this->IndexBufferSize; i++)
145  {
146 
147  shader->VertexShader(this->VertexBuffer, (void*)&(somettransformer[i%3]), NULL, this->IndexBuffer[i], 0);
148 
149 
150  if((i+1)%3 == 0) // si on a trois sommet
151  {
152 
153  AsemblageFacette(somettransformer);
154  somettransformer = new Sommet[3];
155  }
156  }
157 
158  if(Dothread)
159  { // ICI OU ATTEND LA FIN DES THREAD
160  for(unsigned int i = 0; i <m_thread.size();i++ )
161  {
162  m_thread.at(i).join();
163  }
164  m_thread.erase(m_thread.begin(),m_thread.end());
165  }
166 
167 
168 
169 }
170 
176 void Pipeline::AsemblageFacette(Sommet *somettransformer, bool debug)
177 {
178  if(debug)
179  std::cout <<std::endl<<std::endl << "////////////////ETAPE OPERATION ASEMBLAGE FACETTE ////////////////"<< std::endl;
181  if(DoCull)
182  {
183  float nz = ((somettransformer[2].pos.x*somettransformer[1].pos.y)-(somettransformer[1].pos.x*somettransformer[2].pos.y))-
184  ((somettransformer[2].pos.x*somettransformer[0].pos.y)-(somettransformer[0].pos.x*somettransformer[2].pos.y))-
185  ((somettransformer[0].pos.x*somettransformer[1].pos.y)-(somettransformer[1].pos.x*somettransformer[0].pos.y));
186  if(debug)
187  std::cout << "Culling nz : " << nz << std::endl;
188  if(nz < 0)
189  {
190  float fi = 2*1;
191  if(sizeX < sizeY)
192  {
193  fi /= sizeX;
194  }
195  else
196  {
197  fi/= sizeY;
198  }
199 
200  FaceteEcran *facette = new FaceteEcran;
201 
202 
203  facette->som1.x = (somettransformer[0].pos.x/fi) + ((float)sizeX/2.0);
204  facette->som1.y = ((somettransformer[0].pos.y)/fi) + ((float)sizeY/2.0);
205  facette->som2.x = (somettransformer[1].pos.x/fi) + ((float)sizeX/2.0);
206  facette->som2.y = ((somettransformer[1].pos.y)/fi) + ((float)sizeY/2.0);
207  facette->som3.x = (somettransformer[2].pos.x/fi) + ((float)sizeX/2.0);
208  facette->som3.y = ((somettransformer[2].pos.y)/fi) + ((float)sizeY/2.0);
209  if(debug)
210  facette->print();
211  if(DoClip)
212  {
213  if(this->IsOffScreen(facette->som1.x,facette->som1.y) && this->IsOffScreen(facette->som2.x,facette->som2.y) && this->IsOffScreen(facette->som3.x,facette->som3.y))
214  {
215  if(debug)
216  std::cout << "Facette Hors ecran rejeter par le cliping" << std::endl;
217  return;
218  }
219  else
220  {
221  DiscretisationFacette(somettransformer,facette);
222  }
223  }
224  else
225  {
226  DiscretisationFacette(somettransformer,facette);
227  }
228  }
229  else
230  {
231  if(debug)
232  std::cout << "Facette rejeter par l'operation de culling" << std::endl;
233  return;
234  }
235  }
236  else
237  {
238  float fi = 2*1;
239  if(sizeX < sizeY)
240  {
241  fi /= sizeX;
242  }
243  else
244  {
245  fi/= sizeY;
246  }
247 
248  FaceteEcran *facette = new FaceteEcran;
249 
250 
251  facette->som1.x = (somettransformer[0].pos.x/fi) + ((float)sizeX/2.0);
252  facette->som1.y = ((somettransformer[0].pos.y)/fi) + ((float)sizeY/2.0);
253  facette->som2.x = (somettransformer[1].pos.x/fi) + ((float)sizeX/2.0);
254  facette->som2.y = ((somettransformer[1].pos.y)/fi) + ((float)sizeY/2.0);
255  facette->som3.x = (somettransformer[2].pos.x/fi) + ((float)sizeX/2.0);
256  facette->som3.y = ((somettransformer[2].pos.y)/fi) + ((float)sizeY/2.0);
257 
258  if(debug)
259  facette->print();
260 
261  if(DoClip)
262  {
263  if(this->IsOffScreen(facette->som1.x,facette->som1.y) && this->IsOffScreen(facette->som2.x,facette->som2.y) && this->IsOffScreen(facette->som3.x,facette->som3.y))
264  {
265  if(debug)
266  std::cout << "Facette Hors ecran rejeter par le cliping" << std::endl;
267  return;
268  }
269  else
270  {
271  DiscretisationFacette(somettransformer,facette);
272  }
273  }
274  else
275  {
276  DiscretisationFacette(somettransformer,facette);
277  }
278  }
279 
280 
281 
282 }
283 
292 void Pipeline::DiscretisationFacette(Sommet *somettransformer,FaceteEcran *facette)
293 {
294 
295  if(Dothread)
296  { // ICI ON DEMARE ET ATTEND LES THREAD
297  if(m_thread.size() == nbMAXthread)
298  {
299  for(unsigned int i = 0; i <m_thread.size();i++ )
300  {
301  m_thread.at(i).join();
302  }
303  m_thread.erase(m_thread.begin(),m_thread.end());
304  }
305  m_thread.push_back(std::thread(threadRemplissage,this,somettransformer,facette));
306  }
307  else
308  {
309 
310  if(viewPoint)
311  {
312  OperationPixel(coord2d(facette->som1.x,facette->som1.y),this,somettransformer,facette);
313  OperationPixel(coord2d(facette->som2.x,facette->som2.y),this,somettransformer,facette);
314  OperationPixel(coord2d(facette->som3.x,facette->som3.y),this,somettransformer,facette);
315  }
316 
317 
318  // on trace les contour
319  if(viewMaille)
320  {
321  drawLine(somettransformer,this,facette);
322  }
323 
324 
325  if(viewRemplisage)
326  {
327  Remplissage(somettransformer,this,facette);
328  }
329  }
330 }
331 
332 
343 void Pipeline::drawLineNaif(Sommet *somettransformer,Pipeline *monpipeline, FaceteEcran *facette, bool debug)
344 {
345  if(debug)
346  std::cout <<std::endl<<std::endl << "////////////////ETAPE OPERATION TRACAGE LIGNE NAIF PIPELINE////////////////"<< std::endl;
347 
348  point som1 = facette->som1;
349  point som2 = facette->som2;
350  int j;
351  float a, y;
352  for(int p = 0; p < 3; p++)
353  {
354  if(debug)
355  {
356  std::cout << "Tracage du sommet : ";
357  som1.print();
358  std::cout << " au sommet :";
359  som2.print();
360  std::cout << std::endl;
361  }
362  if(p == 1)
363  {
364  som2 = facette->som3;
365  }
366  else if(p == 2) // on trace du sommet 1 a 2
367  {
368  som1 = facette->som2;
369  }
370 
371 
372 
373  if(som2.x != som1.x)
374  a = (float)(som2.y - som1.y) / (float)(som2.x - som1.x);
375  else
376  a = 0;
377 
378 
379  if(debug)
380  std::cout << "Coeficien directeur a : " << a << std::endl;
381 
382  y = som1.y;
383 
384  if(a >= -1 && a <= 1 && som2.x != som1.x)
385  {
386  for(int i = som1.x; i < som2.x; i++)
387  {
388  j= y;
389  OperationPixel(coord2d(i,j),monpipeline,somettransformer,facette);
390  y+=a;
391  }
392  return;
393 
394  }
396 
397  if(a != 0.0)
398  a = (float)(som2.x - som1.x) / (float)(som2.y - som1.y);
399 
400 
401 
402  y = som1.x;
403 
404  for(int i = som1.y; i < som2.y; i++)
405  {
406  j= y;
407  OperationPixel(coord2d(i,j),monpipeline,somettransformer,facette);
408  y+=a;
409  }
410  }
411 }
412 
422 void Pipeline::drawLine(Sommet *somettransformer,Pipeline *monpipeline, FaceteEcran *facette, bool debug)
423 {
424  if(debug)
425  std::cout <<std::endl<<std::endl<< "////////////////ETAPE OPERATION TRACAGE LIGNE PIPELINE////////////////"<< std::endl;
426 
428  point som1 = facette->som1;
429  point som2 = facette->som2;
430 
431  float a;
432  for(int p = 0; p < 3; p++)
433  {
434  if(debug)
435  {
436  std::cout << "Tracage du sommet : ";
437  som1.print();
438  std::cout << " au sommet :";
439  som2.print();
440  std::cout << std::endl;
441  }
442  if(p == 1)
443  {
444  som2 = facette->som3;
445  }
446  else if(p == 2) // on trace du sommet 1 a 2
447  {
448  som1 = facette->som2;
449  }
450 
451  if(som1.x == som2.x && som1.y == som2.y)
452  {
453 
454  }
455  else
456  {
457 
458  if(som2.x != som1.x)
459  {
460  a = (float)(som2.y - som1.y) / (float)(som2.x - som1.x);
461  }
462  else
463  {
464  a = 0.0;
465  }
466 
467 
469  if(a >= 0 && a <= 1 && som2.x != som1.x)
470  {
471  int di = som2.x - som1.x, dj= som2.y - som1.y;
472  int f = (2*dj) -di;
473  int fp = 2*(dj-di), fn = 2* dj;
474  if(debug)
475  std::cout << "fp : " << fp << " fn : " << fn << " f : " << f <<std::endl;
476 
477  for(int i = som1.x, j= som1.y; i < som2.x; i++)
478  {
479  OperationPixel(coord2d(i,j),monpipeline,somettransformer,facette);
480  if(f > 0)
481  {
482  j++;
483  f += fp;
484  }
485  else
486  {
487  f += fn;
488  }
489  }
490 
491  }
492  else if(a < 0 && a >= -1)
493  {
494  int di = som2.x - som1.x, dj= som1.y - som2.y ;
495  int f = (2*dj) -di;
496  int fp = 2*(dj-di), fn = 2* dj;
497  if(debug)
498  std::cout << "fp : " << fp << " fn : " << fn << " f : " << f <<std::endl;
499 
500  for(int i = som1.x, j= som1.y; i < som2.x; i++)
501  {
502 
503  OperationPixel(coord2d(i,j),monpipeline,somettransformer,facette);
504  if(f > 0)
505  {
506  j--;
507  f += fp;
508  }
509  else
510  {
511  f += fn;
512  }
513  }
514  }
515  else
516  {
517 
519 
520 
521  if((a > 1 || a == 0) && som2.y != som1.y)
522  {
523  int di = som2.x - som1.x, dj= som2.y - som1.y;
524  int f = (2*di) -dj;
525  int fp = 2*(di-dj), fn = 2* di;
526 
527  if(debug)
528  printf("som1.x : %d som2.x : %d, som1.y %d som2.y %d fp %d fn %d f %d\n",som1.x,som2.x,som1.y,som2.y,fp,fn,f);
529 
530  for(int i = som1.x, j= som1.y; j < som2.y; j++)
531  {
532  if(debug)
533  printf("paint y %d x %d \n",i,j);
534  OperationPixel(coord2d(i,j),monpipeline,somettransformer,facette);
535  if(f > 0)
536  {
537  i++;
538  f += fp;
539  }
540  else
541  {
542  f += fn;
543  }
544  }
545  }
546  else if(a < -1 && som2.y != som1.y)
547  {
548  int di = som1.x - som2.x , dj= som2.y - som1.y;
549  int f = (2*di) -dj;
550  int fp = 2*(di-dj), fn = 2* di;
551 
552  if(debug)
553  printf("tttsom1.x : %d som2.x : %d, som1.y %d som2.y %d fp %d fn %d f %d\n",som1.x,som2.x,som1.y,som2.y,fp,fn,f);
554 
555  for(int i = som1.x, j= som1.y; j < som2.y; j++)
556  {
557  if(debug)
558  printf("paint y %d x %d \n",i,j);
559 
560  OperationPixel(coord2d(i,j),monpipeline,somettransformer,facette);
561 
562  if(f > 0)
563  {
564  i--;
565  f += fp;
566  }
567  else
568  {
569  f += fn;
570  }
571  }
572  }
573  }
574  }
575  }
576 
577 }
578 
588 void Pipeline::Remplissage(Sommet *somettransformer,Pipeline *monpipeline,FaceteEcran *facette, bool debug)
589 {
590  if(debug)
591  std::cout <<std::endl<<std::endl<< "////////////////ETAPE OPERATION REMPLISSAGE PIPELINE////////////////"<< std::endl;
592 
593  FaceteEcran local = *facette;
594  for(int i = 0; i < 2; i++)
595  {
596  if(local.som2.x < local.som1.x)
597  {
598  std::swap(local.som2,local.som1);
599  }
600  if(local.som3.x < local.som2.x)
601  {
602  std::swap(local.som2,local.som3);
603  }
604  }
605 
606  if(debug)
607  local.print();
608 
609 
610  float dy1, dy2, dy3;
611 
612  if(local.som2.x-local.som1.x > 0)
613  {
614  dy1 = (float)(local.som2.y-local.som1.y) / (float)(local.som2.x-local.som1.x);
615  }
616  else
617  {
618  dy1 = 0.0;
619  }
620  if(local.som3.x-local.som1.x > 0)
621  {
622  dy2 = (float)(local.som3.y-local.som1.y) / (float)(local.som3.x-local.som1.x);
623  }
624  else
625  {
626  dy2 = 0.0;
627  }
628  if(local.som3.x - local.som2.x > 0)
629  {
630  dy3 = (float)(local.som3.y-local.som2.y) / (float)(local.som3.x-local.som2.x);
631  }
632  else
633  {
634  dy3 = 0.0;
635  }
636 
637  float yH = local.som1.y;
638  float yB = local.som1.y;
639 
640  int x = local.som1.x;
641 
642  long val1 = (local.som3.x*local.som2.y)-(local.som3.x*local.som1.y) -(local.som1.x*local.som2.y) -(local.som1.x*local.som1.y);
643  long val2 = (local.som3.y*local.som2.x)-(local.som3.y*local.som1.x) -(local.som1.y*local.som2.x) -(local.som1.y*local.som1.x);
644 
645  if(debug)
646  std::cout << "dy1 : " << dy1 << " dy2 : "<< dy2 << " dy3 : "<<dy3 << std::endl;
647 
648  if(val1 > val2)
649  {
650 
651  while( x < local.som2.x)
652  {
653  if(debug)
654  std::cout << "x : " << x << " yB : "<< yB << " yH : "<<yH << std::endl;
655 
656  for(int y = yB; y < yH; y++)
657  {
658  OperationPixel(coord2d(x,y),monpipeline,somettransformer,facette);
659 
660  }
661  yB += dy2;
662  yH += dy1;
663  x++;
664 
665  }
666  if(local.som1.x == local.som2.x)
667  {
668  yH = local.som2.y;
669  }
670  while( x <= local.som3.x)
671  {
672  if(debug)
673  std::cout << "x : " << x << " yB : "<< yB << " yH : "<<yH << std::endl;
674 
675  for(int y = yB; y < yH; y++)
676  {
677  OperationPixel(coord2d(x,y),monpipeline,somettransformer,facette);
678  }
679  yB += dy2;
680  yH += dy3;
681  x++;
682 
683  }
684  }
685  else
686  {
687  while( x < local.som2.x)
688  {
689  if(debug)
690  std::cout << "x : " << x << " yB : "<< yB << " yH : "<<yH << std::endl;
691 
692  for(int y = yB; y < yH; y++)
693  {
694  OperationPixel(coord2d(x,y),monpipeline,somettransformer,facette);
695  }
696 
697  yB += dy1;
698  yH += dy2;
699  x++;
700  }
701  if(local.som1.x == local.som2.x)
702  {
703  yB = local.som2.y;
704  }
705 
706  while( x <= local.som3.x)
707  {
708  if(debug)
709  std::cout << "x : " << x << " yB : "<< yB << " yH : "<<yH << std::endl;
710 
711 
712  for(int y = yB; y < yH; y++)
713  {
714  OperationPixel(coord2d(x,y),monpipeline,somettransformer,facette);
715  }
716 
717 
718  yB += dy3;
719  yH += dy2;
720  x++;
721  }
722  }
723 }
724 
735 void Pipeline::OperationPixel(coord2d P,Pipeline *monpipeline,Sommet *somettransformer,FaceteEcran *facette,bool debug)
736 {
737  if(debug)
738  std::cout <<std::endl<<std::endl<< "////////////////ETAPE OPERATION PIXEL PIPELINE////////////////"<< std::endl;
739  if(!monpipeline->IsOffScreen(P.x,P.y))
740  {
741  int coordpointtab = (monpipeline->sizeX * P.y) + P.x;
742 
743  float z = zBaricentrique(P,facette,somettransformer);
744  if(debug)
745  {
746  std::cout <<"Position : ";
747  P.print();
748  std::cout << "Z Barycentrique calculer : " << z << " Dans ZBuffer : " << monpipeline->zBuffer[coordpointtab] << std::endl;
749  }
750  if(monpipeline->Dothread)
751  monpipeline->m_mutex.at(P.y)->lock();
752  if(monpipeline->zBuffer[coordpointtab] > z)
753  {
754  pixelOUT out;
755  pixelIN tab;
756  tab.P = P;
757  tab.facette = facette;
758  tab.sommet = somettransformer;
759 
760  monpipeline->shader->PixelShader(&tab,&out,NULL,0,0);
761 
762  monpipeline->zBuffer[coordpointtab] = z;
763  monpipeline->Display[coordpointtab] = out.col;
764 
765  }
766  if(monpipeline->Dothread)
767  monpipeline->m_mutex.at(P.y)->unlock();
768 
769 
770 }
771 
772 }
773 
781 bool Pipeline::IsOffScreen(int x, int y)
782 {
783  if(x < 0 || x >= sizeX || y < 0 || y >= sizeY)
784  {
785  return true;
786  }
787  return false;
788 }
795 {
796  for(long i = 0; i < sizeX * sizeY; i++ )
797  {
798  Display[i].r = Couleur.r;
799  Display[i].b = Couleur.b;
800  Display[i].g = Couleur.g;
801  }
802 }
803 
809 unsigned char * Pipeline::getDisplay()
810 {
811  return (unsigned char *)this->Display;
812 }
818 void Pipeline::ClearZBuffer(float Zmax)
819 {
820  unsigned long taille = sizeX*sizeY;
821  unsigned long i;
822 
823  for(i = 0; i < taille; i++)
824  {
825  zBuffer[i] = Zmax;
826  }
827 }
828 
836 void Pipeline::SetVertexBuffer(unsigned int VBsz, void *VB, unsigned int VSstride)
837 {
838  this->VertexBuffer = VB;
839  this->VertexBufferSize = VBsz;
840  this->VSstride = VSstride;
841 
842 }
843 
850 void Pipeline::SetIndexBuffer(unsigned int IBsz, unsigned int *IB)
851 {
852  this->IndexBuffer = IB;
853  this->IndexBufferSize = IBsz;
854 }
855 
862 {
863  this->shader = VS;
864 }
865 
871 void Pipeline::SaveZBuffer(std::string name)
872 {
873  unsigned char * test = new unsigned char[sizeX* sizeY];
874  unsigned long taille = sizeX*sizeY;
875  unsigned long i;
876 
877 
878  float max = 0;
879  for(i = 0; i < taille; i++)
880  {
881  if(zBuffer[i] > max && zBuffer[i] != FLT_MAX)
882  {
883  max = zBuffer[i];
884 
885  }
886  }
887  float mult = 255/ max ;
888  for(i = 0; i < taille; i++)
889  {
890  if(zBuffer[i] == FLT_MAX)
891  {
892  test[i] = 0;
893  }
894  else
895  {
896  test[i] = zBuffer[i] * mult;
897  }
898  }
899 
900  PgmWrite(sizeX, sizeY, (byte*)test, name.c_str());
901 }
907 void Pipeline::SaveRenderTarget(std::string name)
908 {
909  PpmWrite(sizeX, sizeY, (color*)Display, name.c_str());
910 }
911 
912 
void SetShader(ShaderBase *VS)
Pipeline::SetShader(ShaderBase *VS) Permet de definir le shader qui sera utiliser pour le traitement...
Definition: Pipeline.cpp:861
static void Remplissage(Sommet *somettransformer, Pipeline *monpipeline, FaceteEcran *facette, bool debug=false)
Pipeline::Remplissage(Sommet *somettransformer, FaceteEcran *facette,rgb color, bool debug) Parmet de...
Definition: Pipeline.cpp:588
std::vector< std::thread > m_thread
Definition: Pipeline.h:58
ShaderBase * shader
Pointeur vers une classe shader.
Definition: Pipeline.h:25
bool DoCull
Definition: Pipeline.h:49
unsigned char * getDisplay()
Pipeline::getDisplay() Permet de recuperer le tableau de unsigned char du buffer de rendu...
Definition: Pipeline.cpp:809
void print()
Definition: libMath.h:27
unsigned int VSstride
Definition: Pipeline.h:38
int sizeY
Taille en y de la fenêtre de rendu.
Definition: Pipeline.h:15
rgb * Display
Definition: Pipeline.h:46
void SaveRenderTarget(std::string fichier)
Pipeline::SaveRenderTarget(std::string name) Sauvegarde le resultat du rendu dans un fichier...
Definition: Pipeline.cpp:907
void setCliping(bool var)
Pipeline::setCliping(bool var) Slot permetant de changer si le pipeline utilise le cliping...
Definition: Pipeline.cpp:129
#define max(a, b)
Definition: defUtil.h:30
void AsemblageFacette(Sommet *somettransformer, bool debug=false)
Pipeline::AsemblageFacette(Sommet *somettransformer) Prend les facete et regarde si on peut les élimi...
Definition: Pipeline.cpp:176
void SetVertexBuffer(unsigned int VBsz, void *VB, unsigned int VSstride)
Pipeline::SetVertexBuffer(unsigned int VBsz, void *VB, unsigned int VSstride) Permet de definir le ve...
Definition: Pipeline.cpp:836
void setViewPoint(bool var)
Pipeline::setViewPoint(bool var) Slot permetant de changer la vue du Pipeline en desactivant ou activ...
Definition: Pipeline.cpp:90
float * zBuffer
Definition: Pipeline.h:45
Definition: pgm.h:5
unsigned char r
Definition: definition.h:61
point som2
Definition: definition.h:29
bool viewPoint
Definition: Pipeline.h:54
void PpmWrite(suint sx, suint sy, color *buff, const char *name)
Definition: pgm.cpp:5
unsigned int * IndexBuffer
Pointeur vers le tableau d'index.
Definition: Pipeline.h:19
void DrawTriangles()
Pipeline::DrawTriangles() Lance l'execution du pipeline ! Il commence par envoiyer 3 sommet au vertex...
Definition: Pipeline.cpp:139
unsigned char b
Definition: definition.h:48
void PgmWrite(suint sx, suint sy, byte *buff, const char *name)
Definition: pgm.cpp:14
void DiscretisationFacette(Sommet *somettransformer, FaceteEcran *facette)
Pipeline::DiscretisationFacette(Sommet *somettransformer) Discretise les facette dans le plan de l'éc...
Definition: Pipeline.cpp:292
bool Dothread
Definition: Pipeline.h:52
int x
Definition: definition.h:22
unsigned char r
Definition: definition.h:48
unsigned int nbMAXthread
Definition: Pipeline.h:60
void ClearRenderTarget(defColor::color Couleur)
Pipeline::ClearRenderTarget(defColor::color Couleur) Permet de remplir l'image de buffer avec une cou...
Definition: Pipeline.cpp:794
Sommet * sommet
Definition: definition.h:134
structure pour les vecteurs 3D (de taille 3).
Definition: libMath.h:21
bool IsOffScreen(int x, int y)
Pipeline::IsOffScreen(int x, int y) Permet de savoir si un point est a l'exterieur de la zone visible...
Definition: Pipeline.cpp:781
Pipeline(int sx=600, int sy=600, bool dothread=true)
Pipeline::Pipeline(int sx,int sy) Constructeur du pipeline, par defaut : Culling desactiver Cliping A...
Definition: Pipeline.cpp:14
point som3
Definition: definition.h:30
std::vector< std::mutex * > m_mutex
Definition: Pipeline.h:59
static void threadRemplissage(Pipeline *monpipeline, Sommet *somettransformer, FaceteEcran *facette)
Definition: Pipeline.cpp:57
void SaveZBuffer(std::string name)
Pipeline::SaveZBuffer(std::string name) Sauvegarde le contenu du Zbuffer sous la forme d'une image en...
Definition: Pipeline.cpp:871
unsigned char byte
Definition: pgm.h:2
Classe de gestion du pipeline.
Definition: Pipeline.h:11
void * VertexBuffer
Pointeur vers le tableau de sommets.
Definition: Pipeline.h:18
void setViewRemplisage(bool var)
Pipeline::setViewRemplisage(bool var) Slot permetant de changer la vue du Pipeline en desactivant ou ...
Definition: Pipeline.cpp:110
void setViewMaille(bool var)
Pipeline::setViewMaille(bool var) Slot permetant de changer la vue du Pipeline en desactivant ou acti...
Definition: Pipeline.cpp:99
void SetIndexBuffer(unsigned int IBsz, unsigned int *IB)
Pipeline::SetIndexBuffer(unsigned int IBsz, unsigned int *IB) Permet de definir le vertex buffer qui ...
Definition: Pipeline.cpp:850
~Pipeline()
Destructeur.
Definition: Pipeline.cpp:47
static void drawLine(Sommet *somettransformer, Pipeline *monpipeline, FaceteEcran *facette, bool debug=false)
Pipeline::drawLine(Sommet *somettransformer, FaceteEcran *facette,rgb color, bool debug) Permet de tr...
Definition: Pipeline.cpp:422
bool DoCCW
Definition: Pipeline.h:51
virtual void VertexShader(void *In, void *Out, void *Param, std::size_t Id0, std::size_t Id1)
ShaderBase::VertexShader(void *In, void *Out, void *Param, std::size_t x, std::size_t y) Fonction per...
Definition: ShaderBase.cpp:18
bool viewMaille
Definition: Pipeline.h:55
bool viewRemplisage
Definition: Pipeline.h:56
unsigned int VertexBufferSize
Taille en octet du tableau de sommets (en octets).
Definition: Pipeline.h:21
#define swap(a, b, c)
Definition: defUtil.h:28
unsigned char g
Definition: definition.h:48
float zBaricentrique(Math::coord2d P, FaceteEcran *facette, Sommet *somettransformer)
zBaricentrique(Math::coord2d P,FaceteEcran *facette, Sommet *somettransformer) Fonction permetant de ...
Definition: utils.cpp:19
unsigned char g
Definition: definition.h:61
void print()
Definition: definition.h:31
static void drawLineNaif(Sommet *somettransformer, Pipeline *monpipeline, FaceteEcran *facette, bool debug=false)
Pipeline::drawLineNaif(Sommet *somettransformer, FaceteEcran *facette,rgb color, bool debug) Permet d...
Definition: Pipeline.cpp:343
int sizeX
Taille en x de la fenêtre de rendu.
Definition: Pipeline.h:14
void setCulling(bool var)
Pipeline::setCulling(bool var) Slot permetant de changer si le pipeline utilise le culling...
Definition: Pipeline.cpp:120
FaceteEcran * facette
Definition: definition.h:133
Math::coord2d P
Definition: definition.h:132
Math::vecteur4d pos
Coordonnées du sommet.
Definition: definition.h:76
point som1
Definition: definition.h:28
bool DoClip
Definition: Pipeline.h:50
unsigned int IndexBufferSize
Taille en octet du tableau d'index.
Definition: Pipeline.h:22
unsigned char b
Definition: definition.h:61
void print()
Definition: definition.h:24
static void OperationPixel(coord2d P, Pipeline *monpipeline, Sommet *somettransformer, FaceteEcran *facette, bool debug=false)
Pipeline::OperationPixel(coord2d P,Sommet *somettransformer,FaceteEcran *facette,rgb color...
Definition: Pipeline.cpp:735
int y
Definition: definition.h:23
virtual void PixelShader(void *In, void *Out, void *Param, std::size_t x, std::size_t y)
ShaderBase::PixelShader(void *In, void *Out, void *Param, std::size_t x, std::size_t y) Fonction perm...
Definition: ShaderBase.cpp:52
Definition: definition.h:60
void ClearZBuffer(float Zmax=FLT_MAX)
Pipeline::ClearZBuffer(float Zmax) Permet de remplir le ZBuffer avec la valeur Zmax a toute les cordo...
Definition: Pipeline.cpp:818