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


C++ ShaderProgram::extractActive方法代码示例

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


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

示例1: canExtractEmptyUniformDeclarationWhenNoUniform

    void canExtractEmptyUniformDeclarationWhenNoUniform()
    {
        ShaderProgram shaderProgram;
        addShader(shaderProgram, Shader::FRAGMENT_SHADER, VALID_FRAGMENT_SHADER_SOURCE);
        QVERIFY(shaderProgram.link());

        UniformDeclarationVector uniformDeclarationVector;
        shaderProgram.extractActive(uniformDeclarationVector);

        QVERIFY(uniformDeclarationVector.empty());
    }
开发者ID:spoonless,项目名称:shadercreator,代码行数:11,代码来源:shaderprogramtest.cpp

示例2: canExtractArrayUniformDeclaration

    void canExtractArrayUniformDeclaration()
    {
        ShaderProgram shaderProgram;
        const char* source = \
                "uniform vec4 position[];"\
                "void main() {"\
                " gl_Position = position[0] + position[1] + position[3];"\
                "}";

        addShader(shaderProgram, Shader::VERTEX_SHADER, source);
        QVERIFY(shaderProgram.link());

        UniformDeclarationVector uniformDeclarationVector;
        shaderProgram.extractActive(uniformDeclarationVector);

        QCOMPARE(uniformDeclarationVector.size(), static_cast<size_t>(1));

        QCOMPARE(uniformDeclarationVector[0], UniformDeclaration(0, 4, GL_FLOAT_VEC4, "position[0]"));
    }
开发者ID:spoonless,项目名称:shadercreator,代码行数:19,代码来源:shaderprogramtest.cpp

示例3: canExtractMultipleUniformDeclaration

    void canExtractMultipleUniformDeclaration()
    {
        ShaderProgram shaderProgram;
        const char* source = \
                "uniform vec4 position;"\
                "uniform mat4 mvp;"
                "void main() {"\
                " gl_Position = mvp * position;"\
                "}";

        addShader(shaderProgram, Shader::VERTEX_SHADER, source);
        QVERIFY(shaderProgram.link());

        UniformDeclarationVector uniformDeclarationVector;
        shaderProgram.extractActive(uniformDeclarationVector);

        QCOMPARE(uniformDeclarationVector.size(), static_cast<size_t>(2));

        for (unsigned int i = 0; i < uniformDeclarationVector.size(); ++i)
        {
            UniformDeclaration& uniformDeclaration = uniformDeclarationVector[i];
            QCOMPARE(uniformDeclaration.getIndex(), static_cast<GLuint>(i));
            if (uniformDeclaration.getName() == "position")
            {
                QCOMPARE(uniformDeclaration.getSize(), 1);
                QCOMPARE(uniformDeclaration.getType(), static_cast<GLenum>(GL_FLOAT_VEC4));
            }
            else if (uniformDeclaration.getName() == "mvp")
            {
                QCOMPARE(uniformDeclaration.getSize(), 1);
                QCOMPARE(uniformDeclaration.getType(), static_cast<GLenum>(GL_FLOAT_MAT4));
            }
            else
            {
                QFAIL("unexpected uniform");
            }
        }
    }
开发者ID:spoonless,项目名称:shadercreator,代码行数:38,代码来源:shaderprogramtest.cpp

示例4: canExtractStructArrayUniformDeclaration

    void canExtractStructArrayUniformDeclaration()
    {
        ShaderProgram shaderProgram;
        const char* source = \
                "struct MyStruct {"\
                " vec4 position1[2];"\
                " vec3 position2;"\
                "};"\
                "uniform MyStruct ms[2];"\
                "void main() {"\
                " gl_Position = ms[1].position1[1] + vec4(ms[1].position2, 0);"\
                "}";

        addShader(shaderProgram, Shader::VERTEX_SHADER, source);
        QVERIFY(shaderProgram.link());

        UniformDeclarationVector uniformDeclarationVector;
        shaderProgram.extractActive(uniformDeclarationVector);

        QCOMPARE(uniformDeclarationVector.size(), static_cast<size_t>(2));
        QCOMPARE(uniformDeclarationVector[0], UniformDeclaration(0, 2, GL_FLOAT_VEC4, "ms[1].position1[0]"));
        QCOMPARE(uniformDeclarationVector[1], UniformDeclaration(1, 1, GL_FLOAT_VEC3, "ms[1].position2"));
    }
开发者ID:spoonless,项目名称:shadercreator,代码行数:23,代码来源:shaderprogramtest.cpp


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