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


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

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


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

示例1: Update

	void Update(double time)
	{
		gl.Viewport(size, size);

		fbo.Bind(Framebuffer::Target::Draw);
		Framebuffer::AttachColorTexture(
			Framebuffer::Target::Draw,
			1,
			holder.CurrentHeightMap(),
			0
		);
		Context::ColorBuffer draw_buffs[2] = {
			FramebufferColorAttachment::_0,
			FramebufferColorAttachment::_1
		};
		gl.DrawBuffers(draw_buffs);

		prog.Use();
		prog.hmap_1.Set(holder.HMapUnit1());
		prog.hmap_2.Set(holder.HMapUnit2());
		prog.time.Set(time);

		screen.Use();

		gl.Disable(Capability::DepthTest);
		screen.Draw();
		gl.Enable(Capability::DepthTest);

		holder.Swap();
	}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:30,代码来源:027_flow.cpp

示例2: SetupGeometryBuffer

void GIDeferredRenderer::SetupGeometryBuffer(unsigned windowWidth,
        unsigned windowHeight)
{
    using namespace oglplus;
    static Context gl;
    // initialize geometry buffer
    geometryBuffer.Bind(FramebufferTarget::Draw);
    // build textures -- normal
    gl.Bound(TextureTarget::_2D, bufferTextures[0])
    .Image2D(0, PixelDataInternalFormat::RGBA16F, windowWidth, windowHeight,
             0, PixelDataFormat::RGB, PixelDataType::Float, nullptr)
    .MinFilter(TextureMinFilter::Nearest)
    .MagFilter(TextureMagFilter::Nearest);
    geometryBuffer.AttachColorTexture(FramebufferTarget::Draw, 0, bufferTextures[0],
                                      0);
    // build textures -- albedo
    gl.Bound(TextureTarget::_2D, bufferTextures[1])
    .Image2D(0, PixelDataInternalFormat::RGB8, windowWidth, windowHeight,
             0, PixelDataFormat::RGB, PixelDataType::UnsignedByte, nullptr)
    .MinFilter(TextureMinFilter::Nearest)
    .MagFilter(TextureMagFilter::Nearest);
    geometryBuffer.AttachColorTexture(FramebufferTarget::Draw, 1, bufferTextures[1],
                                      0);
    // build textures -- specular color and shininess
    gl.Bound(TextureTarget::_2D, bufferTextures[2])
    .Image2D(0, PixelDataInternalFormat::RGBA8, windowWidth, windowHeight,
             0, PixelDataFormat::RGBA, PixelDataType::UnsignedByte, nullptr)
    .MinFilter(TextureMinFilter::Nearest)
    .MagFilter(TextureMagFilter::Nearest);
    geometryBuffer.AttachColorTexture(FramebufferTarget::Draw, 2, bufferTextures[2],
                                      0);
    // emissivenes
    gl.Bound(TextureTarget::_2D, bufferTextures[3])
    .Image2D(0, PixelDataInternalFormat::RGB8, windowWidth, windowHeight,
             0, PixelDataFormat::RGB, PixelDataType::UnsignedByte, nullptr)
    .MinFilter(TextureMinFilter::Nearest)
    .MagFilter(TextureMagFilter::Nearest);
    geometryBuffer.AttachColorTexture(FramebufferTarget::Draw, 3, bufferTextures[3],
                                      0);
    // attach depth texture for depth testing
    gl.Bound(TextureTarget::_2D, bufferTextures[4])
    .Image2D(0, PixelDataInternalFormat::DepthComponent24, windowWidth,
             windowHeight, 0, PixelDataFormat::DepthComponent,
             PixelDataType::Float, nullptr)
    .MinFilter(TextureMinFilter::Nearest)
    .MagFilter(TextureMagFilter::Nearest);
    geometryBuffer.AttachTexture(FramebufferTarget::Draw,
                                 FramebufferAttachment::Depth,
                                 bufferTextures[4], 0);
    // color textures
    auto attachments = std::vector<Context::ColorBuffer>
    {
        FramebufferColorAttachment::_0 ,
        FramebufferColorAttachment::_1,
        FramebufferColorAttachment::_2,
        FramebufferColorAttachment::_3
    };
    // set draw buffers
    gl.DrawBuffers(attachments);

    // 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,代码行数:69,代码来源:gi_deferred_renderer.cpp


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