peterhansen
peterhansen

Reputation: 21

Blending two FBOs on iPhone gives strange result?

I am programming a small drawing app on the iphone and ran into a problem. When i merge two fbos the color becomes white instead merging. Look at the picture:

http://dl.dropbox.com/u/2025544/help.png

Here the left is rendered as a normal mac program and the right is rendered on the iPhone platform with almost the same code except for using the eos version of the fbo.

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;

Please help i am going crazy :-)

Upvotes: 2

Views: 468

Answers (2)

peterhansen
peterhansen

Reputation: 21

I solved the problem by not using: glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); I have no idea why this solved it... and it seems that other calls screws things up as well...

Upvotes: 0

Andy J Buchanan
Andy J Buchanan

Reputation: 1950

Did you check what glBlendEquation() is set to?

Upvotes: 1

Related Questions