本文整理汇总了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();
}
示例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));
}