I want to write a program with opengl to project a final rendered image to a scene, which the scene and the image has the same camera view.
I want to use projective texture to do it, so the opengl render effect will be realistic.
Here is my seudo-code.
//1.Bind texture
//2.Enable GL_TEXTURE_GEN_?
GLfloat Splane[4]={1, 0, 0, 0};
GLfloat Tplane[4]={0, 1, 0, 0};
GLfloat Rplane[4]={0, 0, 0, 0};
GLfloat Qplane[4]={0, 0, 0, 1};
glTexGenfv(GL_S,GL_EYE_PLANE,Splane);
glTexGenfv(GL_T,GL_EYE_PLANE,Tplane);
glTexGenfv(GL_R,GL_EYE_PLANE,Rplane);
glTexGenfv(GL_Q,GL_EYE_PLANE,Qplane);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glEnable(GL_TEXTURE_GEN_Q);
//3. Set texture matrix
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
gluPerspective();
gluLookAt();
//4. Draw the scene
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity();
gluPerspective();
gluLookAt();
glMatrixMode(GL_MODEVIEW); // Select The Projection Matrix
glLoadIdentity();
DrawScene();
However, the result is really wierd, the image does not cover the whole scene. I think it might due to the S, T, R, Q Plane parameter. So, how should I set the parameter.
Many thanks!
flex