Multitexturing & Lighting

I’m using the following combiner function:
static GLfloat constColor[4];
constColor[0] = 0.;//material->diffuse[0];
constColor[1] = 0.;//material->diffuse[1];
constColor[2] = 0.;//material->diffuse[2];
constColor[3] = material->m_TexTransparency;
glTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_COLOR,constColor);

				//can't figure out how to not wipe out a fragment's alpha by the
				//incoming texture unit alpha. for now, allow this mode in order
				//to decal 2D text onto a 3DObject.  N.B. in order to do this
				//the 2D text has to be 'Texture 1'
				if(i==0 && m_pModel->materials[group->material].m_bColorIsUsed)
					glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL);
				else
				{
					glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_COMBINE);
					glTexEnvf(GL_TEXTURE_ENV,GL_COMBINE_RGB, GL_INTERPOLATE);
					glTexEnvf(GL_TEXTURE_ENV,GL_SOURCE0_RGB,GL_TEXTURE);
					glTexEnvf(GL_TEXTURE_ENV,GL_OPERAND0_RGB,GL_SRC_COLOR);
					glTexEnvf(GL_TEXTURE_ENV,GL_SOURCE1_RGB,GL_PREVIOUS);
					glTexEnvf(GL_TEXTURE_ENV,GL_OPERAND1_RGB,GL_SRC_COLOR);
					glTexEnvf(GL_TEXTURE_ENV,GL_SOURCE2_RGB,GL_CONSTANT);
					glTexEnvf(GL_TEXTURE_ENV,GL_OPERAND2_RGB,GL_SRC_ALPHA);

this is basically straight out of the red book.
well, here’s what sucks: the last operands perform a weighted blending of texture and previous fragment color. Suppose I set my texture to be fully opaque, all I get for the texel color in that case is the texture color, lighting seems to have no bearing on it at all. How do I get multitexturing working with lighting properly?
Is there a way to do this without resorting to fragment programs?

If this doesn’t belong in beginner forum sorry, the advanced one is closed down.

[This message has been edited by Aeluned (edited 03-11-2004).]

From the FAQ on this site. Hope it helps:

21.030 Why doesn’t lighting work when I turn on texture mapping?

There are many well-meaning texture map demos available on the Web that set the texture environment to GL_DECAL or GL_REPLACE. These environment modes effectively replace the primitive color with the texture color. Because lighting values are calculated before texture mapping (lighting is a per vertex operation, while texture mapping is a per fragment operation), the texture color replaces the colors calculated by lighting. The result is that lighting appears to stop working when texture mapping is enabled.

The default texture environment is GL_MODULATE, which multiplies the texture color by the primitive (or lighting) color. Most applications that use both OpenGL lighting and texture mapping use the GL_MODULATE texture environment.

Look for the following line in your code:

glTexEnv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); /* or GL_REPLACE */You should change GL_DECAL to GL_MODULATE, or simply delete the line entirely (since GL_MODULATE is the default).