TexGen not working in multitexture mode?

In my program, I enable TexGen in texture 0, if I disable texture 1, then everything is ok, but if I enable texture 1, then the generated texture coords of 0 are wrong, why does this happen?

Are you sure you’re enabling TexGen in the correct place, where Texture unit 0 is active. Post up the order of things you do, to determine if something is up there.

What hardware and driver versions are you using? Could you create a demo program, for other people to test, to see if it is your system at fault.

Need more info!!

Nutty

well, here is the code. I am trying to implement a projective texture.

//bind textures
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
g_waveTexture->Activate();

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
g_reflectTexture->Activate();
//set texgen
float ep0[]={1,0,0,0};
float ep1[]={0,1,0,0};
float ep2[]={0,0,1,0};
float ep3[]={0,0,0,1};
glActiveTextureARB(GL_TEXTURE0_ARB);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_S, GL_EYE_PLANE, ep0);
glTexGenfv(GL_T, GL_EYE_PLANE, ep1);
glTexGenfv(GL_R, GL_EYE_PLANE, ep2);
glTexGenfv(GL_Q, GL_EYE_PLANE, ep3);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glEnable(GL_TEXTURE_GEN_Q);
//set the texture matrix
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glLoadIdentity();
glTranslatef(.5f, .5f, 0.f);
glScalef(.5f, .5f, 1.f);

glFrustum(frustum.left,frustum.right,frustum.bottom,frustum.top,frustum.nearp,frustum.farp);

glRotated(camera->GetAngleX(), 1.0, 0.0, 0.0);
glRotated(camera->GetAngleY(), 0.0, 1.0, 0.0);
glRotated(camera->GetAngleZ(), 0.0, 0.0, 1.0);

glTranslatef(-camera->GetX(),-camera->GetY(),-camera->GetZ());
glMatrixMode(GL_MODELVIEW);

//draw a quad
float ww=1024.f;
glBegin(GL_QUADS);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0);
glVertex3f(-ww,-ww,0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,1,0);
glVertex3f(ww,-ww,0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,1,1);
glVertex3f(ww,ww,0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,1);
glVertex3f(-ww,ww,0);
glEnd();

glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_R);
glDisable(GL_TEXTURE_GEN_Q);
glMatrixMode(GL_TEXTURE);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);

at the 3rd line, if I change the function into glDisable(GL_TEXTURE2D), everything is ok.
but whenever I enabled texture 1, then texture0 fails to work. The generated texture coords are correct, but the perspective correction of the texture is wrong.

My card is TNT2 Pro

why the enabling/disabling of texture1 affects the perspective correction of texture0?

forgot to tell, if no rotation is applied to the texture matrix, then enable/disable texture1 produce the same result.

I’m not entirely certain, but I believe that I read in one of nvidia’s papers that TNT class hardware is incapable of doing the perspective divide for texgen on both texture units.

Yes, nvidia mentioned this somewhere on their developer site, but I couldnt find the document. However I did find the following in an article on gamasutra:
http://www.gamasutra.com/features/20000329/gfx_04.htm

One potential pitfall with using projective textures on current consumer hardware is that multiple texture units might actually share the divider gates needed for the hyperbolic interpolator (i.e. the TNT can not do dual projective texturing, while the GeForce can).

Figures…as soon as I post, I find the actual reference from nvidia:
http://www.nvidia.com/Marketing/Develope…l_shadowmap.pdf

from page/slide 30:

NVIDIA’s Projective Texturing Story

Different generations differ
• TNT generation has a single shared hyperbolic interpolator
– independently projected dual textures do not work
– not enough gates for dual- projective in TNT timeframe

• GeForce generation has distinct q/ w hyperbolic interpolators
for both texture units (bigger gate budget buys correctness)
– dual projective textures works

• Not sure what other vendors do