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


C++ IVideoDriver::setShaderProgram方法代码示例

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


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

示例1: initShaders

    void PostProcess::initShaders()
    {
        if (PostProcess::shaderBlurH)
            return;

        file::Zips zp;
        zp.add(system_data, system_size);


        const VertexDeclarationGL* decl = static_cast<const VertexDeclarationGL*>(IVideoDriver::instance->getVertexDeclaration(vertexPCT2::FORMAT));

        file::buffer vs_h;
        file::buffer vs_v;
        file::buffer fs_blur;
        zp.read("system/pp_hblur_vs.glsl", vs_h);
        zp.read("system/pp_vblur_vs.glsl", vs_v);
        zp.read("system/pp_rast_fs.glsl", fs_blur);

        vs_h.push_back(0);
        vs_v.push_back(0);
        fs_blur.push_back(0);


        unsigned int h = ShaderProgramGL::createShader(GL_VERTEX_SHADER, (const char*)&vs_h.front(), "", "");
        unsigned int v = ShaderProgramGL::createShader(GL_VERTEX_SHADER, (const char*)&vs_v.front(), "", "");
        unsigned int ps = ShaderProgramGL::createShader(GL_FRAGMENT_SHADER, (const char*)&fs_blur.front(), "", "");


        IVideoDriver* driver = IVideoDriver::instance;

        shaderBlurV = new ShaderProgramGL(ShaderProgramGL::createProgram(v, ps, decl));
        driver->setShaderProgram(shaderBlurV);
        driver->setUniformInt("s_texture", 0);

        shaderBlurH = new ShaderProgramGL(ShaderProgramGL::createProgram(h, ps, decl));
        driver->setShaderProgram(shaderBlurH);
        driver->setUniformInt("s_texture", 0);


        file::buffer vs_blit;
        file::buffer fs_blit;
        zp.read("system/pp_blit_vs.glsl", vs_blit);
        zp.read("system/pp_blit_fs.glsl", fs_blit);

        vs_blit.push_back(0);
        fs_blit.push_back(0);


        unsigned int vs = ShaderProgramGL::createShader(GL_VERTEX_SHADER, (const char*)&vs_blit.front(), "", "");
        unsigned int fs = ShaderProgramGL::createShader(GL_FRAGMENT_SHADER, (const char*)&fs_blit.front(), "", "");

        shaderBlit = new ShaderProgramGL(ShaderProgramGL::createProgram(vs, fs, decl));
        driver->setShaderProgram(shaderBlit);
        driver->setUniformInt("s_texture", 0);
    }
开发者ID:hicks0074,项目名称:oxygine-framework,代码行数:55,代码来源:PostProcess.cpp


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