Doesnt’ seem to work… in fact, only appears the first texture, and not the second.
Let’s see: my initial, 2-pass blending code is:
//first texture pass
tm.usetexture(12);
for(int i…)
{
glBegin(GL_TRIANGLE_STRIP);
for(int j…)
{
glColor3ub(grayscale color for shading);
glTexCoord2f(…);
glVertex3f(…);
glColor3ub(grayscale...);
glTexCoord2f(....);
glVertex3f(......);
}
glEnd();
}
//end first pass
//second texture pass
glEnable(GL_BLEND);
glDepthFunc(GL_LEQUAL);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
tm.usetexture(11);
for(i…)
{
glBegin(GL_TRIANGLE_STRIP);
for(int j…)
{
// here comes the blending
glColor4ub(…);
glTexCoord2f(…);
glVertex3f(…);
glColor4ub(.........);
glTexCoord2f(........);
glVertex3f(........);
}
glEnd();
}
glDisable(GL_BLEND);
Keep in mind:
- the texcoords,colors are different for both passes
- the blend factor is calculated, does not come from a texture
Ok, so the setup code i use now is:
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
tm.usetexture(12);
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE);
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
tm.usetexture(11);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_INTERPOLATE_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_ALPHA);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_PRIMARY_COLOR_EXT);
And the paint loop is:
for(int i…)
{
glBegin(GL_TRIANGLE_STRIP);
for(int j…)
{
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,…);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,…);
glColor4ub(.......);
glVertex3f(.......);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,.........);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,........);
glColor4ub(.......);
glVertex3f(.......);
}
glEnd();
}
Now, I don’t get it: if we put a color in the loop, it will affect BOTH texturing stages, right?
thankx in advance for looking at this whole mess
[This message has been edited by aphex (edited 05-03-2001).]