FBO and glBlend with correct alpha problem

Hey everyone

I am programming a small drawing app on the iphone and ran into a little problem. I am using ofxFBOTexture and are drawing on two different FBO’s when i print them on the screen with and alpha it look correct (left on the picture). When i try to merge the two into one FBO the alpha looks strange (right picture). The picture is an example where the horisontal line is the one i want to merge with and alpha channel. On the left i am drawing the two fbo’s on top of each other on the other i am drawing one fbo into the other.

Code snippets:

Drawing multiple FBOs on top of each other creates the alpha blending i want:

  
  
		glEnable(GL_BLEND);  
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);  
		myTex.draw(0, 0);  
		  
  
			for(int client = 0; client < 5;client++)  
			{  
				ofSetColor(  
						   datas[client]->myColor.r,  
						   datas[client]->myColor.g,  
						   datas[client]->myColor.b,  
						   datas[client]->myColor.a  
						   );	  
				  
			  
				datas[client]->myTex.draw(0,0);  
				  
			}  
  
	  
  

Merging the two fbos gives med the wrong alpha:

  
  
  
	myTex.begin();  
				glEnable(GL_BLEND);  
				glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);  
  
				  
				ofSetColor(  
						   datas[tmpMessage->clientId]->myColor.r,  
						   datas[tmpMessage->clientId]->myColor.g,  
						   datas[tmpMessage->clientId]->myColor.b,  
						   datas[tmpMessage->clientId]->myColor.a  
						   );  
				datas[tmpMessage->clientId]->myTex.draw(0, 0);  
				  
				myTex.end();  
				datas[tmpMessage->clientId]->myTex.clear(0, 0, 0, 0);  
				  
				datas[tmpMessage->clientId]->touchDown = true;  
  
  

Does anybody have an idea of what i am doing wrong?

Just and update:

ofBackground is the sinner specifically: glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); I have no idea why this solved it… and it seems that other calls screwsthings up as well…

Eg: ofRect also causes problems… maybe something about the smoothing i dont know…

void endSmoothing(){
#ifndef TARGET_OPENGLES
glPopAttrib();
#endif
}

By the way: Let me just say thank you to all of you for the amazing framework in general!!!