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


C++ GLShader::compileLog方法代码示例

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


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

示例1: if

GLShaderProgram*
ShaderBuilder::generateShader(const ShaderInfo& shaderInfo) const
{
    ostringstream vertex;
    ostringstream fragment;

    // Version header (disabled for now)
    // fragment << "#version 120" << endl;

    if (shaderInfo.hasTextureCoord())
    {
        declareVarying(vertex, fragment, "vec2", "texCoord");
    }

    if (shaderInfo.hasVertexColors())
    {
        declareVarying(vertex, fragment, "vec4", "vertexColor");
    }

    //if (shaderInfo.totalLightCount() == 0 || shaderInfo.reflectanceModel() == ShaderInfo::Emissive)
    if (shaderInfo.reflectanceModel() == ShaderInfo::Emissive)
    {
        generateUnlitShader(vertex, fragment, shaderInfo);
    }
    else if (shaderInfo.reflectanceModel() == ShaderInfo::Particulate)
    {
        generateParticulateShader(vertex, fragment, shaderInfo);
    }
    else
    {
        generateBlinnPhongShader(vertex, fragment, shaderInfo);
    }

    VESTA_LOG("Creating shader:  model: %u, textures 0x%x, lights: %u/%u, shadows: %u/%u/%u/%u, scattering: %d, fresnel: %d, vertexColors: %d",
              (int) shaderInfo.reflectanceModel(),
              shaderInfo.textures(),
              shaderInfo.directionalLightCount(),
              shaderInfo.pointLightCount(),
              shaderInfo.shadowCount(), shaderInfo.omniShadowCount(), shaderInfo.eclipseShadowCount(), shaderInfo.hasRingShadows() ? 1 : 0,
              shaderInfo.hasScattering() ? 1 : 0,
              shaderInfo.hasFresnelFalloff() ? 1 : 0,
              shaderInfo.hasVertexColors() ? 1 : 0);

    // Compile the vertex shader
    GLShader* vertexShader = new GLShader(GLShader::VertexStage);
    if (!vertexShader->compile(vertex.str()))
    {
        VESTA_WARNING("Error creating vertex shader:");
        VESTA_WARNING("Error message(s):\n%s", vertexShader->compileLog().c_str());
        VESTA_WARNING("Shader source:\n%s", vertex.str().c_str());
        delete vertexShader;
        return NULL;
    }
    else if (!vertexShader->compileLog().empty())
    {
        VESTA_LOG("Vertex shader compile messages:\n%s", vertexShader->compileLog().c_str());
    }

    // Compile the fragment shader
    GLShader* fragmentShader = new GLShader(GLShader::FragmentStage);
    if (!fragmentShader->compile(fragment.str()))
    {
        VESTA_WARNING("Error creating fragment shader:");
        VESTA_WARNING("Error message(s):\n%s", fragmentShader->compileLog().c_str());
        VESTA_WARNING("Shader source:\n%s", fragment.str().c_str());
        delete vertexShader;
        delete fragmentShader;
        return NULL;
    }
    else if (!fragmentShader->compileLog().empty())
    {
        VESTA_LOG("Vertex shader compile messages:\n%s", fragmentShader->compileLog().c_str());
    }

#if DUMP_SHADER_SOURCE
    VESTA_LOG("Vertex shader source:\n%s", vertex.str().c_str());
    VESTA_LOG("Fragment shader source:\n%s", fragment.str().c_str());
#endif

    // Attach the vertex and fragment shaders
    GLShaderProgram* shaderProgram = new GLShaderProgram();
    shaderProgram->addShader(vertexShader);
    shaderProgram->addShader(fragmentShader);

    // Bind vertex attributes
    if (shaderInfo.hasTexture(ShaderInfo::NormalTexture))
    {
        shaderProgram->bindAttribute("vtxTangent", TangentAttributeLocation);
    }

    // Link the shader program
    if (!shaderProgram->link())
    {
        VESTA_WARNING("Error linking shader program:");
        VESTA_WARNING("Error message(s):\n%s", shaderProgram->log().c_str());
        delete shaderProgram;
        // vertex and fragment shaders automatically deleted along with program
        return NULL;
    }
    else if (!shaderProgram->log().empty())
//.........这里部分代码省略.........
开发者ID:Dwarf-Planet-Project,项目名称:SpaceDesignTool,代码行数:101,代码来源:ShaderBuilder.cpp


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