tags:

views:

182

answers:

2

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 :-)

+1  A: 

Did you check what glBlendEquation() is set to?

Andy J Buchanan
looking through the web it seems glBlendEquation is not a part of the iphone lib?
mads hobye
I've never had cause to change it from the default on any opengl implementation. It's listed in the Khronos openGL ES 2.0 reference, though it looks like the Apple implementation is actually called glBlendEquationOES() which I guess it means it's available as an extension for 1.1. Don't know why the undecorated name isn't available.
Andy J Buchanan
A: 

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...

mads hobye