GL_TEXTURE_ENV_COLOR in the second texture stage.

Working with the fixed pipeline, assuming that in the first texture unit a texture is dot(3)ted with the primary color (set using glColor4f), is it possible (and how) in the second texture unit to modulate the result from previous stage with GL_TEXTURE_ENV_COLOR ?

In the detail, I need to realize the follwing operation (without to bind a 1x1 texture containing color1 in the second texture unit):

out = (tex0 dot3 color0) * color1

I tried with:

glActiveTexture(GL_TEXTURE0);
glColor4f(color0.r, color0.g, color0.b, color0.a);
glEnable(texture.target);
glBindTexture(texture.target, texture.glHandle);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_DOT3_RGBA);
// the first stage (tex0 dot3 color0) works fine!

glActiveTexture(GL_TEXTURE1);
glTexEnvfv(GL_TEXTURE_ENV, GL_TEX_ENV_COLOR, color1);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_CONSTANT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);

but it doesn’t work.

Thanks in advance!

In fixed function, you need to have the unit enabled with a complete texture bound to it, even if the combiner sources don’t access the texture. Otherwise, the unit is treated as disabled.

So, you need a dummy texture, like a 1x1.