本文整理汇总了C++中Context::Finish方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::Finish方法的具体用法?C++ Context::Finish怎么用?C++ Context::Finish使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context::Finish方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void Draw(double time, double fade)
{
// Shadow map
shadows_fbo.Bind(FramebufferTarget::Draw);
gl.Viewport(shadow_size, shadow_size);
gl.Clear().DepthBuffer();
auto light = CamMatrixf::Orbiting(
Vec3f(0, side*0.25, 0),
side*1.5,
Degrees(-time * 27),
Degrees(SineWave(time / 19.0)*25 + 45)
);
shadow_prog.fade.Set(fade);
shadow_prog.camera_matrix.Set(light);
shadow_prog.Use();
shadow_vao.Bind();
gl.Enable(Capability::PolygonOffsetFill);
cube.Draw(side*side);
gl.Disable(Capability::PolygonOffsetFill);
gl.Finish();
// On-screen
default_fb.Bind(Framebuffer::Target::Draw);
gl.Viewport(width, height);
gl.Clear().ColorBuffer().DepthBuffer();
auto camera = CamMatrixf::Orbiting(
Vec3f(),
side*1.1,
Degrees(time * 19),
Degrees(SineWave(time / 20.0) * 39 + 50)
);
display_prog.fade.Set(fade);
display_prog.light_pos.Set(light.Position());
display_prog.camera_pos.Set(camera.Position());
display_prog.light_matrix.Set(light);
display_prog.camera_matrix.Set(camera);
display_prog.Use();
display_vao.Bind();
cube.Draw(side*side);
}
示例2: RenderShadowMap
void RenderShadowMap(GLuint size)
{
// matrices
auto lt_proj= CamMatrixf::PerspectiveX(Degrees(12), 1.0, 85.0, 110.0);
auto light = CamMatrixf::LookingAt(light_position, Vec3f());
// setup the texture
Texture::Active(shadow_tex_unit);
mask_prog.Use();
Uniform<Mat4f>(mask_prog, "LightMatrix").Set(lt_proj*light);
UniformSampler(mask_prog, "ShadowMap").Set(GLuint(shadow_tex_unit));
draw_prog.Use();
Uniform<Mat4f>(draw_prog, "LightMatrix").Set(lt_proj*light);
UniformSampler(draw_prog, "ShadowMap").Set(GLuint(shadow_tex_unit));
Texture::Target tex_tgt = Texture::Target::_2D;
shadow_map.Bind(tex_tgt);
Texture::MinFilter(tex_tgt, TextureMinFilter::Linear);
Texture::MagFilter(tex_tgt, TextureMagFilter::Linear);
Texture::WrapS(tex_tgt, TextureWrap::ClampToEdge);
Texture::WrapT(tex_tgt, TextureWrap::ClampToEdge);
Texture::CompareMode(tex_tgt, TextureCompareMode::CompareRefToTexture);
Texture::Image2D(
tex_tgt,
0,
PixelDataInternalFormat::DepthComponent32,
size, size,
0,
PixelDataFormat::DepthComponent,
PixelDataType::Float,
nullptr
);
// create shadow program
ShadowProgram shadow_prog(vert_shader);
// VAO for the meshes in shadow program
VertexArray vao = meshes.VAOForProgram(shadow_prog);
vao.Bind();
// FBO for offscreen rendering of the shadow map
Framebuffer::Target fbo_tgt = Framebuffer::Target::Draw;
Framebuffer fbo;
fbo.Bind(fbo_tgt);
Framebuffer::AttachTexture(fbo_tgt, FramebufferAttachment::Depth, shadow_map, 0);
// RBO for offscreen rendering
Renderbuffer::Target rbo_tgt = Renderbuffer::Target::Renderbuffer;
Renderbuffer rbo;
rbo.Bind(rbo_tgt);
Renderbuffer::Storage(rbo_tgt, PixelDataInternalFormat::RGBA, size, size);
Framebuffer::AttachRenderbuffer(fbo_tgt, FramebufferAttachment::Color, rbo);
// setup the matrices
shadow_prog.projection_matrix.Set(lt_proj);
shadow_prog.camera_matrix.Set(light);
// setup and clear the viewport
gl.Viewport(size, size);
gl.Clear().DepthBuffer();
// draw the meshes
gl.PolygonOffset(1.0, 1.0);
gl.Enable(Capability::PolygonOffsetFill);
meshes.Draw();
gl.Disable(Capability::PolygonOffsetFill);
gl.Finish();
// bind the default framebuffer
DefaultFramebuffer().Bind(Framebuffer::Target::Draw);
}