首页 > 解决方案 > 在 openFrameworks 中,是否可以在使用 ofxPiMapper 时更改我的 fbo 源的不透明度?

问题描述

在 openFrameworks 中,是否可以在使用 ofxPiMapper 时更改我的 fbo 源的不透明度?

标签: c++mappingopacityopenframeworksfbo

解决方案


弄清楚了:

进入 addons/ofxPiMapper/src/Surfaces/Sur​​faceStack.cpp 在 SurfaceStack::draw() 中,将 ofEnableAlphaBlending() 添加到所有 glblend 内容下方 for 循环内的 if 语句中。

void SurfaceStack::draw(){
    for(int i = 0; i < _surfaces.size(); ++i){
        if(_surfaces[i]->getSource()->getType() == SourceType::SOURCE_TYPE_FBO){
            glEnable(GL_BLEND); 
            glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
            ofEnableAlphaBlending(); //<-- here
        }else{
            ofEnableAlphaBlending();
        }
        _surfaces[i]->draw();
    }
}

推荐阅读