//void alpha(long unsigned int elem1, long unsigned int elem2, long unsigned int elem3) {
void alpha(void) {


        double p1, p2, p3, a1, a2;
        double t1, t2;
	double rcalc, gcalc, bcalc;
	long unsigned int x, y;

//t2 nearest
glBegin(GL_POINTS);
        for(x=0; x < X; x++) {
                for(y=0; y < Y; y++) {
			t2 = depth2[x][y].red +depth2[x][y].green +depth2[x][y].blue;
			//p1 = depth2[x][y].red/(t2+1) * (depth2[x][y].alpha);
			//p2 = depth2[x][y].green/(t2+1) * (depth2[x][y].alpha);
			//p3 = depth2[x][y].blue/(t2+1) * (depth2[x][y].alpha);
			//t2 = p1 + p2 + p3;
			

			
			//t2 = depth2[x][y].red +depth2[x][y].green +depth2[x][y].blue;
			//a1 = depth2[x][y].alpha/255;
			a2 =  (255 - depth1[x][y].alpha);
			//t2 = t2*a1;

			p1 = ( depth2[x][y].red/(t2+1)   )*depth2[x][y].alpha;
			p2 = ( depth2[x][y].green/(t2+1) )*depth2[x][y].alpha;
			p3 = ( depth2[x][y].blue/(t2+1)  )*depth2[x][y].alpha;

			p1 = p1*a2/255;
			p2 = p2*a2/255;
			p3 = p3*a2/255;

			//t2 = p1 + p2 + p3;

			//p1 = (p1/(t2) )*a2;
			//p2 = (p2/(t2) )*a2;
			//p3 = (p3/(t2) )*a2;
			//p1 = (p1/255)*a2;
			//p2 = (p2/255)*a2;
			//p3 = (p3/255)*a2;




			t1 = depth1[x][y].red+depth1[x][y].green+depth1[x][y].blue;
			rcalc = (depth1[x][y].red/(t1+1))*(depth1[x][y].alpha);
			gcalc = (depth1[x][y].green/(t1+1))*(depth1[x][y].alpha);
			bcalc = (depth1[x][y].blue/(t1+1))*(depth1[x][y].alpha); 

			rcalc = rcalc + p1;
			gcalc = gcalc + p2;
			bcalc = bcalc + p3;

			//glBegin(GL_POINTS);
			glColor3f(rcalc / 255, gcalc / 255, bcalc / 255);
			glVertex2f(x, y);
			//glEnd();
		}
	}

	glEnd();


/*      glBegin(GL_POINTS); 
        
        for(counter1=0; counter1 < X; counter1++) {
                for(counter2=0; counter2 < Y; counter2++) {
                        glColor3f( depth2[counter1][counter2].red, depth2[counter1][counter2].green, depth2[counter1][counter2].blue);
                        glVertex2f(counter1, counter2);
                        //glColor3f( depth1[counter1][counter2].red, depth1[counter1][counter2].green, depth1[counter1][counter2].blue);
                        //glVertex2f(counter1, counter2);
         
                
                }
        }
        glEnd();
*/


	
}
