Hi,
i have read the lesson 36 of nehe and i have decided of making my own program about radial blur. But i have a problem :
the big texture that we create and render and witch has like size 640x480 don’t want to be displayed. i don’t understand why !
can you help me ? i really don’t know how to do…
the glutWireCube of the display function is displayed.
this is the code (where i show in commentary what part of the program don’t want to be displayed (at the end)) :
this is first, the main function :
include “main.h”
unsigned int textureNumber ;
Texture *CreateTexture ;void reshape (int w, int h)
{
glViewport (0, 0, w, h) ;glMatrixMode (GL_PROJECTION) ;
glLoadIdentity () ;glFrustum(-5.0 , 5.0, -5.0, 5.0, 5.0, 500.0); //perspective conique
glPushMatrix () ; //permet de revenir à la perspective conique de glFrustum avec glPopMatrixglMatrixMode(GL_MODELVIEW); //la matrice active de modelisation/visualisation sera affectée
glLoadIdentity(); //charge la matrice identitégluLookAt (0, 5, 70, 0, 0, 0, 0, 1, 0) ;
//les 3 premières données sont les coordonnées de la caméra,
//les 3 suivantes désignent la cible, et les 3 suivantes, le haut de la caméra suivant un axe(ici y)}
void display ()
{
glClear (GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT ) ;
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL) ;CreateTexture->RadialBlur() ; //rend dans la texture et la blur
/*AUX_RGBImageRec *texture1;
texture1 = auxDIBImageLoad(“tex.bmp”);
unsigned int texname ;
glGenTextures (1, &texname) ;
glBindTexture (GL_TEXTURE_2D, texname) ;glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR);glTexImage2D(GL_TEXTURE_2D, 0, 3, (texture1)->sizeX, (texture1)->sizeY,
0, GL_RGB, GL_UNSIGNED_BYTE, (texture1)->data);glBindTexture(GL_TEXTURE_2D, texname);
glBegin(GL_QUADS);
glColor3f(1.0,1.0,1.0);
glTexCoord2f(0,0);glVertex2f(-1,-1);
glTexCoord2f(1,0);glVertex2f(1,-1);
glTexCoord2f(1,1);glVertex2f(1,1);
glTexCoord2f(0,1);glVertex2f(-1,1);
glEnd();*/glutWireCube (20) ;
glutSwapBuffers() ;
}
void main (int argc, char** argv)
{//cout<<“hello”<<endl ;
glutInit (&argc, argv) ;
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH) ;
glutInitWindowSize (screenWidth, screenHeight) ;
glutInitWindowPosition (250,250) ;
glutCreateWindow (argv [0]) ;
glClearColor (0.0, 0.5, 0.0, 1.0) ;//glViewport (0, 0, screenWidth, screenHeight) ;
glEnable(GL_TEXTURE_2D);
glEnable( GL_DEPTH_TEST );CreateTexture=new Texture(128) ;//la 1ère variable contient le n°
//de la texture et la 2ème est sa résolution en largeur et hauteurglutReshapeFunc (reshape) ;
glutDisplayFunc (display) ;
glutMainLoop () ;
}
and then the code witch contains the part that seems to be not executed :
#include “main.h”
void Texture::BlendingOrthoOn ()
{
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
glEnable(GL_BLEND);glMatrixMode (GL_PROJECTION) ;
//glLoadIdentity();
glOrtho ( 0, screenWidth , screenHeight , 0, -1, 1) ; //spécifie un repère dont l’origine
//est en haut a gaucheglMatrixMode(GL_MODELVIEW);
//glLoadIdentity();}
void Texture::BlendingOrthoOff ()
{
glMatrixMode (GL_PROJECTION) ;
glPopMatrix () ; //pour revenir aux valeurs de glFrustum qui est dans reshape (fonction main)
glMatrixMode(GL_MODELVIEW);
//glLoadIdentity(); //le remettre pour testglDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
}Texture::Texture(int size)
{
unsigned int *pTexture = NULL;pTexture = new unsigned int [size * size * 4]; // 4= 1 pour chaque composant RGBA
memset(pTexture, 0, size * size * 4 * sizeof(unsigned int));glGenTextures(1, &textureNumber);
glBindTexture(GL_TEXTURE_2D, textureNumber);// Cré la texture et la stocke en mémoire vidéo
glTexImage2D(GL_TEXTURE_2D, 0, 4, size, size, 0, GL_RGBA, GL_UNSIGNED_INT, pTexture);// défini la qualité des textures
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);// Since we stored the texture space with OpenGL, we can delete the image data
delete pTexture;
}void Texture::RadialBlur ()
{
float textureReduction = 0.0 ;
//glPolygonMode (GL_FRONT, GL_LINE) ;
glViewport (0,0,128,128); //réduit a la taille du viewport pour que la texture
//de l’objet fasse 128x128 sinon l’objet serait rendu dans un espace
//plus grand et on prend avec glCopyTexImage2D les 128 premiers
//pixels.glDisable(GL_TEXTURE_2D);
//glutSolidCube (20) ;
glBegin(GL_QUADS);
glColor3f(0.0, 1.0, 1.0) ;
glVertex2f(-10,-10);
glVertex2f(10,-10);
glVertex2f(10,10);
glVertex2f(-10,10);
glEnd();glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,textureNumber);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 0, 0, 128, 128, 0); //copie l’objet
//dans la texture spécifiée en mémoire vidéo
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport(0 , 0,screenWidth ,screenHeight);glBindTexture(GL_TEXTURE_2D,textureNumber); //indique que la texture noire va etre utilisée
CreateTexture->BlendingOrthoOn() ;
//glDisable (GL_BLEND) ;
// it’s here the part that don’t display the square
glBegin(GL_QUADS) ;
for (int num = 0;num <25 ; num++)
{
glColor4f(1.0, 1.0, 1.0, 0.2);
glTexCoord2f(0+textureReduction,1-textureReduction);
glVertex2f(0,0);glTexCoord2f(0+textureReduction,0+textureReduction); glVertex2f(0,480); glTexCoord2f(1-textureReduction,0+textureReduction); glVertex2f(640,480); glTexCoord2f(1-textureReduction,1-textureReduction); glVertex2f(640,0); textureReduction = textureReduction + 0.02; }
glEnd();
CreateTexture->BlendingOrthoOff() ;
}
[This message has been edited by airseb (edited 06-23-2003).]