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


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

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


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

示例1: canCopyProgram

    void canCopyProgram()
    {
        ShaderProgram shaderProgram;

        Shader fragmentShader(Shader::FRAGMENT_SHADER);
        fragmentShader.compile(VALID_FRAGMENT_SHADER_SOURCE);
        shaderProgram.attach(fragmentShader);

        Shader vertexShader(Shader::VERTEX_SHADER);
        vertexShader.compile(VALID_VERTEX_SHADER_SOURCE);
        shaderProgram.attach(vertexShader);

        ShaderProgram copy = shaderProgram;

        QVERIFY(copy.exists());
        QVERIFY(copy.getId() != 0);
        QVERIFY(glIsProgram(copy.getId()));
        QVERIFY(copy.has(fragmentShader));
        QVERIFY(copy.has(vertexShader));
        QVERIFY(copy.link());
    }
开发者ID:spoonless,项目名称:shadercreator,代码行数:21,代码来源:shaderprogramtest.cpp

示例2: id

BuiltIns::BuiltIns()
{
    sw::ResourceId id(Id(0), Id(0));

    id.resource = Id("Shader.TextureFontText.vertex");
    try
    {
        Shader* shader = new Shader(id, Shader::TVertex,
            "#version 330\n\n"
            "uniform mat4 transform;\n\n"
            "layout(location = 0) in vec2 in_position;\n"
            "layout(location = 1) in vec2 in_texcoord;\n\n"
            "out vec2 texcoord;\n\n"
            "void main()\n"
            "{\n"
            "   texcoord = in_texcoord;\n"
            "   gl_Position = transform * vec4(in_position, 0.0, 1.0);\n"
            "}\n");
        shaders_.insert(std::make_pair(shader->getId().resource, std::unique_ptr<Shader>(shader)));
    }
    catch (const std::exception& err)
    {
        logWarning("Shader", id, err.what());
    }

    id.resource = Id("Shader.TextureFontText.fragment");
    try
    {
        Shader* shader = new Shader(id, Shader::TFragment,
            "#version 330\n\n"
            "uniform vec4 color;\n"
            "uniform sampler2D texsampler;\n\n"
            "in vec2 texcoord;\n\n"
            "layout(location = 0) out vec4 out_fragcolor;\n\n"
            "void main()\n"
            "{\n"
            "   out_fragcolor = vec4(color.rgb, color.a * texture(texsampler, texcoord).r);\n"
            "}\n");
        shaders_.insert(std::make_pair(shader->getId().resource, std::unique_ptr<Shader>(shader)));
    }
    catch (const std::exception& err)
    {
        logWarning("Shader", id, err.what());
    }

    id.resource = Id("ShaderProgram.TextureFontText");
    try
    {
        ShaderProgram* program = new ShaderProgram(id,
            getShader(Id("Shader.TextureFontText.vertex")), 
            getShader(Id("Shader.TextureFontText.fragment")));
        programs_.insert(std::make_pair(program->getId().resource, std::unique_ptr<ShaderProgram>(program)));
    }
    catch (const std::exception& err)
    {
        logWarning("Program", id, err.what());
    }

    id.resource = Id("Texture.TextureFont.default");
    try
    {
        const GLubyte* data = reinterpret_cast<const GLubyte*>(
            "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52"
            "\x00\x00\x00\x80\x00\x00\x00\x80\x08\x03\x00\x00\x00\xF4\xE0\x91"
            "\xF9\x00\x00\x00\x19\x74\x45\x58\x74\x53\x6F\x66\x74\x77\x61\x72"
            "\x65\x00\x41\x64\x6F\x62\x65\x20\x49\x6D\x61\x67\x65\x52\x65\x61"
            "\x64\x79\x71\xC9\x65\x3C\x00\x00\x03\x66\x69\x54\x58\x74\x58\x4D"
            "\x4C\x3A\x63\x6F\x6D\x2E\x61\x64\x6F\x62\x65\x2E\x78\x6D\x70\x00"
            "\x00\x00\x00\x00\x3C\x3F\x78\x70\x61\x63\x6B\x65\x74\x20\x62\x65"
            "\x67\x69\x6E\x3D\x22\xEF\xBB\xBF\x22\x20\x69\x64\x3D\x22\x57\x35"
            "\x4D\x30\x4D\x70\x43\x65\x68\x69\x48\x7A\x72\x65\x53\x7A\x4E\x54"
            "\x63\x7A\x6B\x63\x39\x64\x22\x3F\x3E\x20\x3C\x78\x3A\x78\x6D\x70"
            "\x6D\x65\x74\x61\x20\x78\x6D\x6C\x6E\x73\x3A\x78\x3D\x22\x61\x64"
            "\x6F\x62\x65\x3A\x6E\x73\x3A\x6D\x65\x74\x61\x2F\x22\x20\x78\x3A"
            "\x78\x6D\x70\x74\x6B\x3D\x22\x41\x64\x6F\x62\x65\x20\x58\x4D\x50"
            "\x20\x43\x6F\x72\x65\x20\x35\x2E\x30\x2D\x63\x30\x36\x31\x20\x36"
            "\x34\x2E\x31\x34\x30\x39\x34\x39\x2C\x20\x32\x30\x31\x30\x2F\x31"
            "\x32\x2F\x30\x37\x2D\x31\x30\x3A\x35\x37\x3A\x30\x31\x20\x20\x20"
            "\x20\x20\x20\x20\x20\x22\x3E\x20\x3C\x72\x64\x66\x3A\x52\x44\x46"
            "\x20\x78\x6D\x6C\x6E\x73\x3A\x72\x64\x66\x3D\x22\x68\x74\x74\x70"
            "\x3A\x2F\x2F\x77\x77\x77\x2E\x77\x33\x2E\x6F\x72\x67\x2F\x31\x39"
            "\x39\x39\x2F\x30\x32\x2F\x32\x32\x2D\x72\x64\x66\x2D\x73\x79\x6E"
            "\x74\x61\x78\x2D\x6E\x73\x23\x22\x3E\x20\x3C\x72\x64\x66\x3A\x44"
            "\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E\x20\x72\x64\x66\x3A\x61"
            "\x62\x6F\x75\x74\x3D\x22\x22\x20\x78\x6D\x6C\x6E\x73\x3A\x78\x6D"
            "\x70\x4D\x4D\x3D\x22\x68\x74\x74\x70\x3A\x2F\x2F\x6E\x73\x2E\x61"
            "\x64\x6F\x62\x65\x2E\x63\x6F\x6D\x2F\x78\x61\x70\x2F\x31\x2E\x30"
            "\x2F\x6D\x6D\x2F\x22\x20\x78\x6D\x6C\x6E\x73\x3A\x73\x74\x52\x65"
            "\x66\x3D\x22\x68\x74\x74\x70\x3A\x2F\x2F\x6E\x73\x2E\x61\x64\x6F"
            "\x62\x65\x2E\x63\x6F\x6D\x2F\x78\x61\x70\x2F\x31\x2E\x30\x2F\x73"
            "\x54\x79\x70\x65\x2F\x52\x65\x73\x6F\x75\x72\x63\x65\x52\x65\x66"
            "\x23\x22\x20\x78\x6D\x6C\x6E\x73\x3A\x78\x6D\x70\x3D\x22\x68\x74"
            "\x74\x70\x3A\x2F\x2F\x6E\x73\x2E\x61\x64\x6F\x62\x65\x2E\x63\x6F"
            "\x6D\x2F\x78\x61\x70\x2F\x31\x2E\x30\x2F\x22\x20\x78\x6D\x70\x4D"
            "\x4D\x3A\x4F\x72\x69\x67\x69\x6E\x61\x6C\x44\x6F\x63\x75\x6D\x65"
            "\x6E\x74\x49\x44\x3D\x22\x78\x6D\x70\x2E\x64\x69\x64\x3A\x37\x37"
            "\x31\x38\x44\x42\x46\x34\x45\x45\x45\x38\x45\x32\x31\x31\x41\x36"
            "\x38\x45\x44\x37\x33\x37\x34\x30\x32\x36\x39\x36\x38\x30\x22\x20"
            "\x78\x6D\x70\x4D\x4D\x3A\x44\x6F\x63\x75\x6D\x65\x6E\x74\x49\x44"
            "\x3D\x22\x78\x6D\x70\x2E\x64\x69\x64\x3A\x31\x34\x32\x36\x31\x43"
//.........这里部分代码省略.........
开发者ID:bcrist,项目名称:PBJgame,代码行数:101,代码来源:built_ins.cpp


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