how to take the two different textures into one texture?

how to take the two different textures into one texture according a mask bitmap? What I mean is I put the one tex into the white areas of the mask bitmap,at the same time,put the other tex into the black areas.And then,I can gain a wonderful texture that form by the two texs based on the mask.
If I can realize the function,I will create many different masks,such as masks that made of many non-rectangle,white areas and many non-rectangle(star-shaped) areas.
After thinking about this problem for several months,I find I can’t solve it at ease.Must I use the edge-detect algorithm? Otherwise,I can’t put the tex into respective color-areas(white or black) fitly and seamlessly.
Any helps are appreciated.

the main question is how to adapt to many different type mask bitmap.

I had an idea that I can gain and save the edge vertex data of all areas,and then sort those vertex based on CCW or CW,lastly,I render the shape using those vertex and map the respective texture on it.But what about non-convex areas?
So confused.

You can apply the textures in a single rendering pass using multitexturing (glMultiTexCoord) with the two textures and the mask loaded into 3 different textures and assigned to 3 different texture units using glActiveTexture.

Make use of ARB_texture_env_* or NV_register_combiners extensions to correctly setup the texture-combining mode.

Documentation of these extensions are available at
http://oss.sgi.com/projects/ogl-sample/registry/

N.

thanks in advance,But I think multitexture extension can solve the problem I mentioned.Can you give some details(sourcecode) on how to realize?I know multitexture extension and can use it freely.But I have not got an idea .
Thank you again!

go to http:
ehe.gamedev.net
there you should find plenty ogl tutorials,
on multitexturing as well.

using texture_env_combine you could combine the textures
you would need to set texenvf(GL_COMBINE)
and then combine_RGB to INTERPOLATE

perform a “search” on these forums looking for “combine” that alone should give you some threads with similar problem and source codes

nehe tutorials are too easy to solve my problem.I just want to map some screenshot in order to explain my trouble,But I can’t make it,can you tell me how to upload some pictures in this forum?
another question:If I have an array stored disorderly many points,which is gained from detecting the edges of 0-1 bitmap,how can I turn those points sequence into Clockwise-Ordered points sequence?
i.e. Assume that the array pt[0]={1,1} pt[1]={0,0},pt[2]={0,1},pt[3]={1,0},pt[4]=…,
I want the CCW sequence,that is,pt[0]={1,1},pt[1]={0,1},pt[2]={0,0},pt[3]={1,0}…,you know.
Perhaps a sort algorithm!
Thank you !

I think the problem is you asking for image processing / data algorithms
while people here would help on how to set up things in OGL to combine textures and whatnot. but not the creation of pixels based on some sort of algorithm as you seem to need it.
check the algorithm forum maybe thats better

or I completely misunderstood your problem.