开发者

Blending two FBOs on iPhone gives strange result?

开发者 https://www.devze.com 2022-12-16 04:47 出处:网络
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:

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, 开发者_如何学Python0);


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


Did you check what glBlendEquation() is set to?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消