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