Salut tout le monde
Certains vont surement dire "A nan encore lui" lol. Oui je sais mais je suis pas très fort. Bon cette fois j'ai une image au format tga avec des pixels complement transparents. Mais quand je les affiche avec OpenGL ces pixels s'affichent en noir.
Voila le code:
Initialisation de glut:
Et la la texture a ete chargée(Je met pas le code du loader c'est trop long):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 glClearColor(.0,.0,.0,0); //Initialize the background color: black glClearDepth(1.0); glEnable(GL_DEPTH_TEST); //Activate the depth test glEnable(GL_TEXTURE_2D);//On activate the texturing glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
ou Color et Position sont 2 structures dont les composantes sont Red,Green,Blue et x,y,z respectivement.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 glBindTexture(GL_TEXTURE_2D,Id); glEnable(GL_BLEND); glBegin(GL_QUADS); glColor3ub(Color.Red,Color.Green,Color.Blue);glTexCoord2i(0,1);glVertex3i(Position.x,Position.y,Position.z); glTexCoord2i(1,1);glVertex3i(Position.x+Size.x,Position.y,Position.z); glTexCoord2i(1,0);glVertex3i(Position.x+Size.x,Position.y-Size.y,Position.z); glTexCoord2i(0,0);glVertex3i(Position.x,Position.y-Size.y,Position.z); glEnd(); glDisable(GL_BLEND);
Merci
Partager