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


C++ ProgramPtr::Use方法代码示例

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


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

示例1: drawSphereBackground

void EdvsRiftApp::drawSphereBackground(int camera_id)
{
    static ProgramPtr program = oria::loadProgram("./resources/sphere_background.vs", "./resources/sphere_background.fs");
    static ShapeWrapperPtr geometry = ShapeWrapperPtr(new shapes::ShapeWrapper({ "Position" }, shapes::ObjMesh(mesh_input.stream), *program));

    // Reset before application exit
    Platform::addShutdownHook([]
    {
        program.reset();
        geometry.reset();
    });


    MatrixStack & mv = Stacks::modelview();

    mv.withPush([&]
    {
        // Binds the program
        program->Use();

        // Matrices as uniforms
        Mat4Uniform(*program, "ModelView").Set(Stacks::modelview().top());
        Mat4Uniform(*program, "Projection").Set(Stacks::projection().top());

        // Draw this
        geometry->Use();
        geometry->Draw();
    });

    // Unbind
    oglplus::NoProgram().Bind();
    oglplus::NoVertexArray().Bind();
}
开发者ID:stefan-urban,项目名称:oculus-client,代码行数:33,代码来源:EdvsRiftApp.cpp

示例2: drawEvents

void EdvsRiftApp::drawEvents()
{
    static ProgramPtr program = oria::loadProgram("./resources/event_pixel.vs", "./resources/event_pixel.fs");

    // Reset before application exit
    Platform::addShutdownHook([]
    {
        program.reset();
    });


    MatrixStack & mv = Stacks::modelview();

    mv.withPush([&]
    {
        // Binds the program
        program->Use();

        // Matrices as uniforms
        Mat4Uniform(*program, "ModelView").Set(Stacks::modelview().top());
        Mat4Uniform(*program, "Projection").Set(Stacks::projection().top());

        // Manual set for azimuth and elevation
        oglplus::Uniform<float>(*program, "ManAzimuth").Set(azimuth);
        oglplus::Uniform<float>(*program, "ManElevation").Set(elevation);

        // Manual set for field of view
        oglplus::Uniform<float>(*program, "FovX").Set(60.0 * DEGREES_TO_RADIANS);
        oglplus::Uniform<float>(*program, "FovY").Set(60.0 * DEGREES_TO_RADIANS);


        // Bind VAO
        vao->Bind();

        // Bind VBO "Positions"
        vbo_position->Bind(Buffer::Target::Array);
        {
            Buffer::Data(Buffer::Target::Array, position_);

            VertexArrayAttrib vao_attr(*program, "Position");
            vao_attr.Setup<Vec2f>();
            vao_attr.Enable();
        }

        // Bind VBO "CameraId"
        vbo_camera_id->Bind(Buffer::Target::Array);
        {
            Buffer::Data(Buffer::Target::Array, camera_id_);

            VertexArrayAttrib vao_attr(*program, "CameraId");
            vao_attr.Setup<Vec1f>();
            vao_attr.Enable();
        }

        // Bind VBO "Color"
        vbo_color->Bind(Buffer::Target::Array);
        {
            Buffer::Data(Buffer::Target::Array, parity_); //, BufferUsage::StreamDraw);

            VertexArrayAttrib vao_attr(*program, "Color");
            vao_attr.Setup<Vec1f>();
            vao_attr.Enable();
        }

        // Draw all elements
        Context::DrawArrays(PrimitiveType::Points, 0, camera_id_.size());
    });

    // Unbind
    oglplus::NoProgram().Bind();
    oglplus::NoVertexArray().Bind();
}
开发者ID:stefan-urban,项目名称:oculus-client,代码行数:72,代码来源:EdvsRiftApp.cpp


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