multi-texturing

SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_BLENDTEXTUREALPHA);

anyone knows how to write these three lines in opengl?

Or you can do it via shaders.

thanks for the advice. can you please tell me how can i do it with fixed function pipe line?

What I want to do is this. Please advice with opengl fixed function pipe line. Thanks a million.

Arg1 * (Alpha) + Alg2 * ( 1 - Alpha )

If you insist on FFP, I think you’ll want to look at the texture environment functions (glTexEnv), specifically COMBINE with the BLEND flavor for that operation. (Looks like this is covered in § 3.8.13 of the 2.1 spec, p. 184. Nicely summarized in the man pages too: http://www.opengl.org/sdk/docs/man/ )

Oops… I guess that should be the INTERPOLATE function for combine RGB/ALPHA, not BLEND (same idea though).

As a side note, it us pretty funny that somebody insists on using FFP in a post in the “OpenGL Shading Language” section of the forum :slight_smile:

If I remember correctly, this is what I used:

glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);

Thanks for the reply, I will try with it.

On second thought:

This is not what you need. You have to use GL_DECAL on all but GL_TEXTURE0 (for which GL_MODULATE is my usual choice) to get an alpha composite.

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)

It really is more straighforward using GLSL than the fixed pipeline.

I have made it. Here is the code for what I wanted.
Thanks everybody.

glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB_ARB,GL_INTERPOLATE_ARB);

glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_PRIMARY_COLOR);

glTexEnvi(GL_TEXTURE_ENV, GL_SRC2_RGB, GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_ARB, GL_SRC_ALPHA);

You may notice there is no Arg1. It doesn’t matter for me. It works fine for me.