当前位置: 首页>>代码示例>>C++>>正文


C++ FrameBufferObject::getDrawBuffersInUse方法代码示例

本文整理汇总了C++中FrameBufferObject::getDrawBuffersInUse方法的典型用法代码示例。如果您正苦于以下问题:C++ FrameBufferObject::getDrawBuffersInUse方法的具体用法?C++ FrameBufferObject::getDrawBuffersInUse怎么用?C++ FrameBufferObject::getDrawBuffersInUse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FrameBufferObject的用法示例。


在下文中一共展示了FrameBufferObject::getDrawBuffersInUse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateFrom

bool ImageGL::updateFrom(const ImageGL* source) {
    ImageGL* target = this;

    // Primarily Copy by FBO blitting, all from source FBO to target FBO
    const FrameBufferObject* srcFBO = source->getFBO();
    FrameBufferObject* tgtFBO = target->getFBO();
    const Texture2D* sTex = source->getColorLayerGL()->getTexture().get();
    Texture2D* tTex = target->getColorLayerGL()->getTexture().get();

    const std::vector<bool>& srcBuffers = srcFBO->getDrawBuffersInUse();
    const std::vector<bool>& targetBuffers = tgtFBO->getDrawBuffersInUse();
    srcFBO->setRead_Blit();
    tgtFBO->setDraw_Blit();
    GLbitfield mask = GL_COLOR_BUFFER_BIT;

    if (srcFBO->hasDepthAttachment() && tgtFBO->hasDepthAttachment()) mask |= GL_DEPTH_BUFFER_BIT;

    if (srcFBO->hasStencilAttachment() && tgtFBO->hasStencilAttachment())
        mask |= GL_STENCIL_BUFFER_BIT;

    glBlitFramebufferEXT(0, 0, static_cast<GLint>(sTex->getWidth()),
                         static_cast<GLint>(sTex->getHeight()), 0, 0,
                         static_cast<GLint>(tTex->getWidth()),
                         static_cast<GLint>(tTex->getHeight()), mask, GL_NEAREST);
    bool pickingCopied = false;

    for (int i = 1; i < srcFBO->getMaxColorAttachments(); i++) {
        if (srcBuffers[i] && targetBuffers[i]) {
            glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + i);
            glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT + i);
            glBlitFramebufferEXT(
                0, 0, static_cast<GLint>(sTex->getWidth()), static_cast<GLint>(sTex->getHeight()),
                0, 0, static_cast<GLint>(tTex->getWidth()), static_cast<GLint>(tTex->getHeight()),
                GL_COLOR_BUFFER_BIT, GL_NEAREST);

            if (GL_COLOR_ATTACHMENT0_EXT + i == static_cast<int>(pickingAttachmentID_))
                pickingCopied = true;
        }
    }

    glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
    glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
    srcFBO->setRead_Blit(false);
    tgtFBO->setDraw_Blit(false);

    LGL_ERROR;

    // Secondary copy using PBO

    // Depth texture
    if ((mask & GL_DEPTH_BUFFER_BIT) == 0) {
        sTex = source->getDepthLayerGL()->getTexture().get();
        tTex = target->getDepthLayerGL()->getTexture().get();

        if (sTex && tTex) tTex->loadFromPBO(sTex);
    }

    LGL_ERROR;

    // Picking texture
    if (!pickingCopied && pickingAttachmentID_ != 0) {
        sTex = source->getPickingLayerGL()->getTexture().get();
        tTex = target->getPickingLayerGL()->getTexture().get();

        if (sTex && tTex) tTex->loadFromPBO(sTex);
    }

    LGL_ERROR;
    return true;
}
开发者ID:ResearchDaniel,项目名称:inviwo,代码行数:70,代码来源:imagegl.cpp


注:本文中的FrameBufferObject::getDrawBuffersInUse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。