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


C++ Context::DrawBuffer方法代码示例

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


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

示例1: SetupFramebuffers

void ShadowMapRenderer::SetupFramebuffers(const unsigned &w,
        const unsigned &h)
{
    using namespace oglplus;
    static Context gl;
    // save size
    shadowMapSize = glm::uvec2(w, h);
    // setup shadow framebuffer
    shadowFramebuffer.Bind(FramebufferTarget::Draw);
    // create render buffer for depth testing
    depthRender.Bind(RenderbufferTarget::Renderbuffer);
    depthRender.Storage(RenderbufferTarget::Renderbuffer,
                        PixelDataInternalFormat::DepthComponent24, w, h);
    // create variance shadow mapping texture, z and z * z
    gl.Bound(TextureTarget::_2D, shadowMap)
    .Image2D(0, PixelDataInternalFormat::RGBA32F, w, h, 0,
             PixelDataFormat::RGBA, PixelDataType::Float, nullptr);
    Filtering(filtering);
    Anisotropy(8);
    shadowFramebuffer.AttachColorTexture(FramebufferTarget::Draw, 0, shadowMap, 0);
    shadowFramebuffer.AttachRenderbuffer(FramebufferTarget::Draw,
                                         FramebufferAttachment::Depth,
                                         depthRender);
    gl.DrawBuffer(FramebufferColorAttachment::_0);

    // check if success building frame buffer
    if (!Framebuffer::IsComplete(FramebufferTarget::Draw))
    {
        auto status = Framebuffer::Status(FramebufferTarget::Draw);
        Framebuffer::HandleIncompleteError(FramebufferTarget::Draw, status);
    }

    Framebuffer::Bind(Framebuffer::Target::Draw, FramebufferName(0));
    // setup shadow blur framebuffer
    blurFramebuffer.Bind(FramebufferTarget::Draw);
    // create variance shadow mapping texture, z and z * z
    gl.Bound(TextureTarget::_2D, blurShadow)
    .Image2D(0, PixelDataInternalFormat::RGBA32F, w, h, 0,
             PixelDataFormat::RGBA, PixelDataType::Float, nullptr)
    .MinFilter(TextureMinFilter::Linear).MagFilter(TextureMagFilter::Linear)
    .WrapS(TextureWrap::ClampToEdge).WrapT(TextureWrap::ClampToEdge).Anisotropy(8);
    blurFramebuffer.AttachColorTexture(FramebufferTarget::Draw, 0, blurShadow, 0);
    gl.DrawBuffer(FramebufferColorAttachment::_0);

    // check if success building frame buffer
    if (!Framebuffer::IsComplete(FramebufferTarget::Draw))
    {
        auto status = Framebuffer::Status(FramebufferTarget::Draw);
        Framebuffer::HandleIncompleteError(FramebufferTarget::Draw, status);
    }

    Framebuffer::Bind(Framebuffer::Target::Draw, FramebufferName(0));
}
开发者ID:Alan-Baylis,项目名称:VCTRenderer,代码行数:53,代码来源:shadow_map_renderer.cpp

示例2: Render

    void Render(double time)
    {
        flow.Update(time);

        Framebuffer::BindDefault(Framebuffer::Target::Draw);
        gl.DrawBuffer(ColorBuffer::BackLeft);
        gl.Viewport(width, height);
        gl.Clear().ColorBuffer().DepthBuffer();

        screen_prog.Use();
        screen.Use();
        screen.Draw();
    }
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:13,代码来源:027_flow.cpp

示例3: Render

    void Render(double time)
    {
        //
        // the camera matrix
        Mat4f camera = CamMatrixf::Orbiting(
            Vec3f(),
            6.5 + SineWave(time / 16.0) * 1.5,
            FullCircles(time / 12.0),
            Degrees(SineWave(time / 30.0) * 90)
        );
        //
        // the model matrix
        Mat4f model = ModelMatrixf::RotationA(
            Vec3f(1.0f, 1.0f, 1.0f),
            FullCircles(time / 10.0)
        );
        // the light position
        Vec3f lightPos(0.0f, SineWave(time / 7.0) * 0.5, 0.0f);
        //
        SetProgramUniform(shape_prog, "LightPos", lightPos);
        SetProgramUniform(depth_prog, "LightPos", lightPos);
        SetProgramUniform(light_prog, "LightPos", lightPos);
        //
        SetProgramUniform(shape_prog, "CameraMatrix", camera);
        SetProgramUniform(light_prog, "CameraMatrix", camera);

        SetProgramUniform(shape_prog, "ModelMatrix", model);
        SetProgramUniform(depth_prog, "ModelMatrix", model);

        // render the shadow map
        depth_fbo.Bind(Framebuffer::Target::Draw);
        gl.DrawBuffer(ColorBuffer::None);

        gl.Viewport(tex_side, tex_side);
        gl.Clear().DepthBuffer();

        depth_prog.Use();
        shape.Bind();
        shape_instr.Draw(shape_indices);

        // render the output frame
        Framebuffer::BindDefault(Framebuffer::Target::Draw);
        gl.DrawBuffer(ColorBuffer::Back);

        gl.Viewport(width, height);
        gl.Clear().ColorBuffer().DepthBuffer();


        shape_prog.Use();
        shape.Bind();
        shape_instr.Draw(shape_indices);

        gl.Enable(Capability::Blend);

        light_prog.Use();
        SetUniform(light_prog, "ViewX", camera.Row(0).xyz());
        SetUniform(light_prog, "ViewY", camera.Row(1).xyz());
        SetUniform(light_prog, "ViewZ", camera.Row(2).xyz());

        light.Bind();
        gl.DrawArraysInstanced(
            PrimitiveType::Points,
            0, 1,
            sample_count
        );

        gl.Disable(Capability::Blend);
    }
开发者ID:xdray,项目名称:oglplus,代码行数:68,代码来源:030_shadow_volume.cpp


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