Probleme OPENGL , affichage des couleurs en non transparence

Probleme OPENGL , affichage des couleurs en non transparence - C++ - Programmation

Marsh Posté le 09-07-2002 à 17:14:00    

voila mon pobleme , je me suis crévé le cul à dessiner 3 axes (x,y,z) en polygone afin d'attibuer une couleur à chacun .le probleme est que la couleur rouge de l'axe x prédomine sur les autre et l'on est vite perdu .
aidez moi svp  
 
 
 //axe y
 {
   
 //arriere
  glBegin(GL_POLYGON);
   glNormal3d(0.0,0.0,1.0);
   glColor3ub(0,0,255);
   {
    glVertex3d( -petite_distance, petite_distance ,longue_distance  );
    glVertex3d( 0 ,petite_distance , longue_distance );
    glVertex3d(0, 0 , longue_distance );
    glVertex3d(-petite_distance , 0 , longue_distance);
   }
 
  glEnd();
 
 //avant  
   glBegin(GL_POLYGON);
   glNormal3d(0.0,0.0,-1.0);
   glColor3ub(0,0,255);
   {
    glVertex3d( -petite_distance ,petite_distance  ,petite_distance );
    glVertex3d( 0 , petite_distance , petite_distance );
    glVertex3d(0 , 0 , petite_distance );
    glVertex3d(-petite_distance, 0  , petite_distance );
   }
  glEnd();
 
 //dessus
  glBegin(GL_POLYGON);
   glNormal3d(0.0,1.0,0.0);
   glColor3ub(0,0,255);
   {
    glVertex3d( -petite_distance ,petite_distance  ,petite_distance );
    glVertex3d( 0 , petite_distance , petite_distance );
    glVertex3d( 0 ,petite_distance , longue_distance );
    glVertex3d( -petite_distance, petite_distance ,longue_distance  );
     
     
   }
  glEnd();
 
 //dessous
  glBegin(GL_POLYGON);
   glNormal3d(0.0,-1.0,0.0);
   glColor3ub(0,0,255);
   {
    glVertex3d( -petite_distance , 0 , longue_distance );
    glVertex3d( 0 , 0 , longue_distance );
    glVertex3d( 0 , 0 ,  petite_distance);
    glVertex3d( -petite_distance , 0, petite_distance );
   }
  glEnd();
 
 //gauche
  glBegin(GL_POLYGON);
   glNormal3d(-1.0,0.0,0.0);
   glColor3ub(0,0,255);
   {
    glVertex3d(-petite_distance,petite_distance,petite_distance);
    glVertex3d(-petite_distance,petite_distance,longue_distance);
    glVertex3d( -petite_distance,0,longue_distance);
    glVertex3d(-petite_distance,0,petite_distance);
   }
  glEnd();
 
 //droite
  glBegin(GL_POLYGON);
   glNormal3d(1.0,0.0,0.0);
   glColor3ub(0,0,255);
   {
    glVertex3d( 0,0,petite_distance );
     
    glVertex3d(0,0,longue_distance);
   
    glVertex3d( 0,petite_distance,longue_distance);
   
    glVertex3d(0,petite_distance,petite_distance);
     
   }
  glEnd();
 
 }
 
 //Axe Z
 {
   
 //arriere
  glBegin(GL_POLYGON);
   glNormal3d(0.0,0.0,1.0);  
   glVertex3d(-petite_distance,longue_distance,petite_distance);
   glColor3ub(0,255,0);
   glVertex3d( 0,longue_distance,petite_distance);
   glColor3ub(0,255,0);
   glVertex3d(0,0,petite_distance);
   glColor3ub(0,255,0);
   glVertex3d(-petite_distance,0,petite_distance);
  glEnd();
 
 //avant  
   glBegin(GL_POLYGON);
   glNormal3d(0.0,0.0,-1.0);
   glVertex3d(-petite_distance,longue_distance,0);
   glColor3ub(0,255,0);
   glVertex3d(0,longue_distance,0);
   glColor3ub(0,255,0);
   glVertex3d(0,0,0);
   glColor3ub(0,255,0);
   glVertex3d(-petite_distance,0,0);
  glEnd();
 
 //dessus
  glBegin(GL_POLYGON);
   glNormal3d(0.0,1.0,0.0);
   glColor3ub(0,255,0);
   glVertex3d(-petite_distance,longue_distance,petite_distance);
   glColor3ub(0,255,0);
   glVertex3d(0,longue_distance,petite_distance);
   glColor3ub(0,255,0);
   glVertex3d(0,longue_distance,0);
   glColor3ub(0,255,0);
   glVertex3d( -petite_distance,longue_distance,0);
  glEnd();
 
 //dessous
  glBegin(GL_POLYGON);
   glNormal3d(0.0,-1.0,0.0);
   glColor3ub(0,255,0);
   glVertex3d(-petite_distance,0,petite_distance);
   glColor3ub(0,255,0);
   glVertex3d( 0,0,petite_distance);
   glColor3ub(0,255,0);
   glVertex3d(0,0,0);
   glColor3ub(0,255,0);
   glVertex3d( -petite_distance,0,0);
  glEnd();
 
 //gauche
  glBegin(GL_POLYGON);
   glNormal3d(-1.0,0.0,0.0);
   glColor3ub(0,255,0);
   glVertex3d(-petite_distance,longue_distance,0);
   glColor3ub(0,255,0);
   glVertex3d( -petite_distance,longue_distance,petite_distance);
   glColor3ub(0,255,0);
   glVertex3d(-petite_distance,0,petite_distance);
   glColor3ub(0,255,0);
   glVertex3d(-petite_distance,0,0);
  glEnd();
 
 //droite
  glBegin(GL_POLYGON);
   glNormal3d(1.0,0.0,0.0);
   glColor3ub(0,255,0);
   glVertex3d(0,longue_distance,0);
   glColor3ub(0,255,0);
   glVertex3d( 0,longue_distance,petite_distance);
   glColor3ub(0,255,0);
   glVertex3d(0,0,petite_distance);
   glColor3ub(0,255,0);
   glVertex3d(0,0,0);
  glEnd();
 
 }
 
 //Axe -X
 {
   
 //arriere
  glBegin(GL_POLYGON);
   glNormal3d(0.0,0.0,1.0);  
   glVertex3d(-longue_distance,petite_distance,petite_distance);
   glColor3ub(255,0,0);
   glVertex3d( -petite_distance,petite_distance,petite_distance);
   glColor3ub(255,0,0);
   glVertex3d(-petite_distance,0,petite_distance);
   glColor3ub(255,0,0);
   glVertex3d(-longue_distance,0,petite_distance);
  glEnd();
 
 //avant  
/*   glBegin(GL_POLYGON);
   glNormal3d(0.0,0.0,-1.0);
   glVertex3d(-petite_distance,longue_distance,0);
   glColor3ub(255,0,0);
   glVertex3d(0,longue_distance,0);
   glColor3ub(255,0,0);
   glVertex3d(0,0,0);
   glColor3ub(255,0,0);
   glVertex3d(-petite_distance,0,0);
  glEnd();*/

 //dessus
  glBegin(GL_POLYGON);
   glNormal3d(0.0,1.0,0.0);
   glColor3ub(255,0,0);
   glVertex3d(-longue_distance,petite_distance,0);
   glColor3ub(255,0,0);
   glVertex3d(-petite_distance,petite_distance,0);
   glColor3ub(255,0,0);
   glVertex3d(-petite_distance,0,0);
   glColor3ub(255,0,0);
   glVertex3d( -longue_distance,0,0);
  glEnd();
 
 //dessous
  glBegin(GL_POLYGON);
   glNormal3d(0.0,-1.0,0.0);
   glColor3ub(255,0,0);
   glVertex3d(-longue_distance,0,petite_distance);
   glColor3ub(255,0,0);
   glVertex3d( -petite_distance,0,petite_distance);
   glColor3ub(255,0,0);
   glVertex3d(-petite_distance,0,0);
   glColor3ub(255,0,0);
   glVertex3d( -longue_distance,0,0);
  glEnd();
 
 //gauche
  glBegin(GL_POLYGON);
   glNormal3d(-1.0,0.0,0.0);
   glColor3ub(255,0,0);
   glVertex3d(-longue_distance,petite_distance,0);
   glColor3ub(255,0,0);
   glVertex3d( -longue_distance,petite_distance,petite_distance);
   glColor3ub(255,0,0);
   glVertex3d(-longue_distance,0,petite_distance);
   glColor3ub(255,0,0);
   glVertex3d(-longue_distance,0,0);
  glEnd();
 
 //droite
/*  glBegin(GL_POLYGON);
   glNormal3d(1.0,0.0,0.0);
   glColor3ub(0,0,255);
   glVertex3d(0,longue_distance,0);
   glColor3ub(0,0,255);
   glVertex3d( 0,longue_distance,petite_distance);
   glColor3ub(0,0,255);
   glVertex3d(0,0,petite_distance);
   glColor3ub(0,0,255);
   glVertex3d(0,0,0);
  glEnd();*/

 
 }

Reply

Marsh Posté le 09-07-2002 à 17:14:00   

Reply

Marsh Posté le 09-07-2002 à 18:02:09    

As-tu pensé a activer le test du Z-Buffer ??
 
glEnable( GL_DEPTH_TEST );
 
...
 
rendu des axes...

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed