Hi,

I have successfully ran my code of blending of two images with supplied blending factor.This code works good when the images are read from hard drive, but when I use one of image which is created by my program and one image read from memory the blending is not working.

I am using texture combiners for blending my images.

This is how I am creating my image.
Code :
 
void gen_texture(void){
 
 int i,j;
 GLubyte waveTex[200][200][4];
 for (i=0;i<n;i++){
	 for (j=0;j<n;j++){
		 	 waveTex[i][j][0] = 100;
			 waveTex[i][j][1] = 215;
			 waveTex[i][j][2] = 100; 
			 waveTex[i][j][3] = 255; 
	 }
  }
 }

And following is the code for blending two images. I am unable to figure out why the code is not working with generated image.
textureArray[0] is first image from memory
textureArray[1] is second image from memory
textureArray[2] program generated image

Code :
 
glEnable(GL_BLEND);
 
	glActiveTextureARB(GL_TEXTURE0);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D,  textureArray[0]);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
 
//------------------------
// Following part of code generates the texture	
	gen_texture();
	glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
	glGenTextures(1, &amp;textureArray[2]);
    //glBindTexture(GL_TEXTURE_2D, textureArray[2]);
 
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST);
 
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, n, n, 0, GL_RGBA, GL_UNSIGNED_BYTE,	waveTex);
        glActiveTextureARB(GL_TEXTURE1);
	glEnable(GL_TEXTURE_2D);
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
        glBindTexture(GL_TEXTURE_2D, textureArray[2]);
 
	//----------------------------------------------------
// if I use this following commented part of code the the code works as it blends two images from the memory	
 
 
       /*glActiveTextureARB(GL_TEXTURE1);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D,  textureArray[1]);*/
 
 
    //--------------COMBINER FUNCTIONS--------------------------//
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
	glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);   //Interpolate RGB with RGB
	glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
	glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE);
	//GL_CONSTANT refers to the call we make with glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, mycolor)
	glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_CONSTANT);
	glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
	glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
	glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_COLOR);
	//------------------------
	glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_INTERPOLATE);   //Interpolate ALPHA with ALPHA
	glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
	glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE);
	//GL_CONSTANT refers to the call we make with glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, mycolor)
	glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, GL_CONSTANT);
	glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
	glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
	glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, GL_SRC_ALPHA);
	//------------------------
	float mycolor[4];
	mycolor[0]=mycolor[1]=mycolor[2]=0.5;    
	mycolor[3]=0.5;         //Set the blend factor 
	glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, mycolor);
 
	//Set the blend factor with this
	glPushMatrix();
	glTranslatef(-(n/2),-(n/2),0);
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_NORMAL_ARRAY);
 
 
	glClientActiveTexture(GL_TEXTURE0_ARB); 
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glTexCoordPointer(2,GL_FLOAT,0,tex);
 
	glClientActiveTexture(GL_TEXTURE1_ARB); 
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glTexCoordPointer(2,GL_FLOAT,0,tex);
 
	glNormalPointer(GL_FLOAT, 0, normals);
	glVertexPointer(3,GL_FLOAT,0,vertices);
	glDrawElements(GL_TRIANGLES,6*(n-1)*(n-1),GL_UNSIGNED_INT,indices);
 
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glClientActiveTexture(GL_TEXTURE0); 	
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisable (GL_TEXTURE_2D);
	glActiveTextureARB(GL_TEXTURE0_ARB); //ensure we finish on texture unit #0
	glDisable(GL_BLEND);
	glPopMatrix();


Thank you,
Paras_woLf