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


C++ JSONValue::getJSONValue方法代码示例

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


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

示例1: init

void RenderStage::init(const JSONValue& renderStageJSON)
{
    auto renderStageRenderPassesJSON = renderStageJSON.getJSONValue("renderPasses");
    if(!renderStageRenderPassesJSON.isNull())
    {
        for(unsigned int i = 0; i < renderStageRenderPassesJSON.getSize(); ++i)
            if(!renderStageRenderPassesJSON.getJSONArrayItem(i).isNull())
                renderPasses.pushBack(createRenderPassFromJson(renderStageRenderPassesJSON.getJSONArrayItem(i)));
    }
}
开发者ID:A-K,项目名称:Huurre3D,代码行数:10,代码来源:RenderStage.cpp

示例2: init

void DeferredStage::init(const JSONValue& deferredgStageJSON)
{
    auto gbufferRenderPassJSON = deferredgStageJSON.getJSONValue("GbufferRenderPass");
    if(!gbufferRenderPassJSON.isNull())
        renderPasses.pushBack(createRenderPassFromJson(gbufferRenderPassJSON));
}
开发者ID:A-K,项目名称:Huurre3D,代码行数:6,代码来源:DeferredStage.cpp

示例3: createRenderPassFromJson

RenderPass RenderStage::createRenderPassFromJson(const JSONValue& renderPassJSON)
{
    GraphicSystem& graphicSystem = renderer.getGraphicSystem();

    RenderPass renderPass;
    auto clearColorJSON = renderPassJSON.getJSONValue("clearColor");
    auto colorWriteJSON = renderPassJSON.getJSONValue("colorWrite");
    auto depthWriteJSON = renderPassJSON.getJSONValue("depthWrite");
    auto renderTargetLayerJSON = renderPassJSON.getJSONValue("renderTargetLayer");
    auto flagsJSON = renderPassJSON.getJSONValue("flags");

    if(!clearColorJSON.isNull())
        renderPass.clearColor = clearColorJSON.getVector4();
    if(!colorWriteJSON.isNull())
        renderPass.colorWrite = colorWriteJSON.getBool();
    if(!depthWriteJSON.isNull())
        renderPass.depthWrite = depthWriteJSON.getBool();
    if(!renderTargetLayerJSON.isNull())
        renderPass.renderTargetLayer = renderTargetLayerJSON.getInt();
    if(!flagsJSON.isNull())
    {
        unsigned int flags = 0;
        for(unsigned int i = 0; i < flagsJSON.getSize(); ++i)
        {
            if(flagsJSON.getJSONArrayItem(i).getString().compare("CLEAR_COLOR") == 0)
                flags |= CLEAR_COLOR;
            if(flagsJSON.getJSONArrayItem(i).getString().compare("CLEAR_DEPTH") == 0)
                flags |= CLEAR_DEPTH;
        }
        renderPass.flags = flags;
    }

    auto viewPortJSON = renderPassJSON.getJSONValue("viewPort");
    if(!viewPortJSON.isNull())
    {
        FixedArray<int, 4> viewPort = viewPortJSON.getInt4();
        renderPass.viewPort.set(viewPort[0], viewPort[1], viewPort[2], viewPort[3]);
    }
    else
        renderPass.viewPort = renderer.getScreenViewPort();

    auto renderTargetJSON = renderPassJSON.getJSONValue("renderTarget");
    renderPass.renderTarget = graphicSystem.createRenderTarget(renderTargetJSON);

    auto shaderPasses = renderPassJSON.getJSONValue("shaderPasses");

    if(!shaderPasses.isNull())
    {
        for(unsigned int i = 0; i < shaderPasses.getSize(); ++i)
        {
            auto shaderPassJSON = shaderPasses.getJSONArrayItem(i);
            auto programJSON = shaderPassJSON.getJSONValue("shaderProgram");
            auto vertexDataJSON = shaderPassJSON.getJSONValue("vertexData");
            auto rasterStateJSON = shaderPassJSON.getJSONValue("rasterState");
            auto shaderParameterBlocksJSON = shaderPassJSON.getJSONValue("shaderParameterBlocks");
            auto texturesJSON = shaderPassJSON.getJSONValue("textures");
            ShaderPass shaderPass;

            if(!vertexDataJSON.isNull())
            {
                if(vertexDataJSON.getString().compare("fullScreenQuad") == 0)
                    shaderPass.vertexData = renderer.getFullScreenQuad();
            }
            if(!rasterStateJSON.isNull())
            {
                auto blendFunctionJSON = rasterStateJSON.getJSONValue("blendFunction");
                auto compareFunctionJSON = rasterStateJSON.getJSONValue("compareFunction");
                auto cullFaceJSON = rasterStateJSON.getJSONValue("cullFace");
                auto blendState = !blendFunctionJSON.isNull() ? BlendState(true, enumFromString<BlendFunction>(blendFunctionJSON.getString())) : BlendState(false, BlendFunction::Replace);
                auto compareState = !compareFunctionJSON.isNull() ? CompareState(true, enumFromString<CompareFunction>(compareFunctionJSON.getString())) : CompareState(false, CompareFunction::Never);
                auto cullState = !cullFaceJSON.isNull() ? CullState(true, enumFromString<CullFace>(cullFaceJSON.getString())) : CullState(false, CullFace::Back);
                shaderPass.rasterState = RasterState(blendState, compareState, cullState);
            }

            if(!shaderParameterBlocksJSON.isNull())
            {
                for(unsigned int j = 0; j < shaderParameterBlocksJSON.getSize(); ++j)
                {
                    ShaderParameterBlock* block = graphicSystem.createShaderParameterBlock(shaderParameterBlocksJSON.getJSONArrayItem(j));
                    if(block)
                        shaderPass.shaderParameterBlocks.pushBack(block);
                }
            }
            if(!texturesJSON.isNull())
            {
                for(unsigned int j = 0; j < texturesJSON.getSize(); ++j)
                {
                    Texture* texture = graphicSystem.createTexture(texturesJSON.getJSONArrayItem(j));
                    if(texture)
                        shaderPass.textures.pushBack(texture);
                }
            }

            if(!programJSON.isNull())
                shaderPass.program = graphicSystem.createShaderProgram(programJSON);

            renderPass.shaderPasses.pushBack(shaderPass);
        }
    }
    return renderPass;
//.........这里部分代码省略.........
开发者ID:A-K,项目名称:Huurre3D,代码行数:101,代码来源:RenderStage.cpp


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