vincent0 | Hello.
J'essaye de faire un rendu sur texture mais j'ai un écran tout blanc, pourquoi ? :
A l'initialisation de ma fenêtre, je fait ceci : Code :
- glGenTextures(1, &textureID);
- glBindTexture (GL_TEXTURE_2D, textureID);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
Quand on redimensionne la fenêtre, je fait ceci : Code :
- unsigned int *pTexture = new unsigned int[width*height*3];
- glBindTexture (GL_TEXTURE_2D, textureID);
- glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0, GL_RGB, GL_UNSIGNED_INT, pTexture);
- delete [] pTexture;
|
Rendu : Code :
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- glLoadIdentity();
- glDrawBuffer(GL_AUX0); //on dessine le triangle dans un buffer auxilliaire
- glReadBuffer(GL_AUX0);
- glBegin(GL_TRIANGLES);
- glColor3f(1.0, 1.0, 1.0); glVertex3f(-1.0, -1.0, -7.0);
- glColor3f(0.0, 0.0, 0.0); glVertex3f(1.0, -1.0, -7.0);
- glColor3f(0.5, 0.5, 0.5); glVertex3f(0.0, 1.0, -7.0);
- glEnd();
- glBindTexture (GL_TEXTURE_2D, textureID);
- glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, width, height, 0); //copie le buffer auxilliaire dans une texture
- glDrawBuffer(GL_BACK);
- glReadBuffer(GL_BACK);
- //On se projette en vision orthogonale (2D) et on affiche la texture
- glDisable(GL_DEPTH_TEST);
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho(0, 1, 0, 1, -1, 1);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
- glBegin(GL_QUADS);
- glColor4f(1.0, 1.0, 1.0, 0.5);
- glTexCoord2f(0.0, 0.0); glVertex2i(0, 0);
- glTexCoord2f(0.0, 1.0); glVertex2i(0, 1);
- glTexCoord2f(1.0, 1.0); glVertex2i(1, 1);
- glTexCoord2f(1.0, 0.0); glVertex2i(1, 0);
- glEnd();
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
- glMatrixMode(GL_MODELVIEW);
- glPopMatrix();
- glEnable(GL_DEPTH_TEST);
|
Merci... |