A poser une question, peut-être que quelqu'un peut m'aider. J'essaye de créer un effet miroir en utilisant OpenGL. Je dessine un plan transparent, une scène "réfléchie" coupée au pochoir, et une originale. Mais j'ai un "mur" complètement non-transparent au lieu du miroir. Je sais que cela arrive à cause du premier rendu du plan miroir (pour obtenir un tampon stencil). Mais je ne sais pas quoi faire avec ce :( Voici le code:Problèmes de fusion (OpenGL)
void CMirror::draw(CSceneObject * curscene)
{
glPushMatrix();
glClearStencil(0.0f);
glClear(GL_STENCIL_BUFFER_BIT);
//Draw into the stencil buffer
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glStencilFunc(GL_ALWAYS, 1, 0);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glEnable(GL_STENCIL_TEST);
glPushMatrix();
glTranslatef(this->coords[0], this->coords[1], this->coords[2]);
glScalef(this->size, this->size, this->size);
glColor4f(1, 0, 1, 0);
glBegin(GL_QUADS);
glVertex3f(0.0f, this->height/2.0f, this->width/2.0f);
glVertex3f(0.0f, this->height/-2.0f, this->width/2.0f);
glVertex3f(0.0f, this->height/-2.0f, this->width/-2.0f);
glVertex3f(0.0f, this->height/2.0f, this->width/-2.0f);
glEnd();
glPopMatrix();
glDisable(GL_STENCIL_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
//glClear(GL_COLOR_BUFFER_BIT);
//Draw the scene
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_EQUAL, 1, 255);
glPushMatrix();
glTranslatef(2*this->coords[0], 2*this->coords[1], 2*this->coords[2]);
glScalef(-1.0f, 1.0f, 1.0f);
((CScene*)curscene)->draw();
glColor4f(0.0f, 0.30f, 0, 0.9);
((CScene*)curscene)->spline->draw();
((CScene*)curscene)->morph->draw();
glPopMatrix();
glDisable(GL_STENCIL_TEST);
//the mirror itself:
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glPushMatrix();
glTranslatef(this->coords[0], this->coords[1], this->coords[2]);
glScalef(this->size, this->size, this->size);
glColor4f(0, 0, 0, 0.9);
glBegin(GL_QUADS);
glVertex3f(0.0f, this->height/2.0f, this->width/2.0f);
glVertex3f(0.0f, this->height/-2.0f, this->width/2.0f);
glVertex3f(0.0f, this->height/-2.0f, this->width/-2.0f);
glVertex3f(0.0f, this->height/2.0f, this->width/-2.0f);
glEnd();
glPopMatrix();
glDisable(GL_BLEND);
glPopMatrix();
}
Bahbar, merci! glClear (GL_DEPTH_BUFFER_BIT) a fonctionné :)) Et j'ai enlevé le dernier tirage, ça n'avait vraiment aucun sens :)) – Irene