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


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

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


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

示例1: updateStageData

void DeferredShadingStage::updateStageData(
    DSStageData         *data,
    FrameBufferObject   *shadingTarget,
    RenderPartition     *parentPart    )
{
    FrameBufferObject *gBufferTarget = data->getGBufferTarget();

    Int32 targetWidth;
    Int32 targetHeight;
    Int32 targetLeft;
    Int32 targetBottom;

    if(shadingTarget != NULL)
    {
        targetWidth  = shadingTarget->getWidth ();
        targetHeight = shadingTarget->getHeight();

        targetLeft   = 0;
        targetBottom = 0;
    }
    else
    {
        targetWidth  = parentPart->getDrawEnv().getPixelWidth ();
        targetHeight = parentPart->getDrawEnv().getPixelHeight();

        targetLeft   = parentPart->getDrawEnv().getPixelLeft  ();
        targetBottom = parentPart->getDrawEnv().getPixelBottom();
    }

    if(gBufferTarget->getWidth () != targetWidth ||
       gBufferTarget->getHeight() != targetHeight  )
    {
        _targetSizeChanged = true;
    }

    if(_targetSizeChanged == true)
    {
        gBufferTarget->setSize(targetWidth, targetHeight);
    }

    if(getMFPixelFormats()->size() != getMFPixelTypes()->size())
    {
        SWARNING << "DeferredShadingStage::updateStageData: "
                 << "Number of PixelFormats and PixelTypes inconsistent."
                 << std::endl;
    }

    UInt32 lightCount  =        getMFLights      ()->size();
    UInt32 bufferCount = osgMin(getMFPixelFormats()->size(),
                                getMFPixelTypes  ()->size() );

    // buffers changed - remove them here, recreate below
    if((_changeCache & (PixelFormatsFieldMask |
                        PixelTypesFieldMask    )) != 0)
    {
        gBufferTarget->editMFColorAttachments()->clear (                    );
        gBufferTarget->editMFColorAttachments()->resize(bufferCount, NULL   );
        gBufferTarget->editMFDrawBuffers     ()->clear (                    );
        gBufferTarget->editMFDrawBuffers     ()->resize(bufferCount, GL_NONE);
    }

    for(UInt32 i = 0; i < bufferCount; ++i)
    {
        TextureBuffer *buf =
            dynamic_cast<TextureBuffer *>(gBufferTarget->getColorAttachments(i));

        if(buf == NULL)
        {
            TextureBufferUnrecPtr newBuf =
                createGBuffer(i, targetWidth, targetHeight);
            buf = newBuf;

            gBufferTarget->editMFColorAttachments()->replace(i, newBuf                      );
            gBufferTarget->editMFDrawBuffers     ()->replace(i, GL_COLOR_ATTACHMENT0_EXT + i);
        }
        else
        {
            updateGBuffer(buf, i, targetWidth, targetHeight);
        }
    }

    if((_changeCache & LightsFieldMask) != 0)
    {
        data->editMFLightChunks         ()->resize(    lightCount, NULL);
        data->editMFShadingStates       ()->resize(1 + lightCount, NULL);
        data->editMFShadingProgramChunks()->resize(1 + lightCount, NULL);
    }

    // update shading states
    if((_changeCache & (PixelFormatsFieldMask   |
                        PixelTypesFieldMask     |
                        AmbientProgramFieldMask |
                        LightProgramsFieldMask  |
                        LightsFieldMask          )) != 0)
    {
        // copy ambient and light programs
        DSStageData::MFShadingProgramChunksType::const_iterator spcIt  =
            data->editMFShadingProgramChunks()->begin();
        DSStageData::MFShadingProgramChunksType::const_iterator spcEnd =
            data->editMFShadingProgramChunks()->end  ();
//.........这里部分代码省略.........
开发者ID:DaveHarrison,项目名称:OpenSGDevMaster,代码行数:101,代码来源:OSGDeferredShadingStage.cpp


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