本文整理汇总了C++中Context::ColorMask方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::ColorMask方法的具体用法?C++ Context::ColorMask怎么用?C++ Context::ColorMask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context::ColorMask方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
void Render(double time)
{
gl.Clear().ColorBuffer().DepthBuffer().StencilBuffer();
// make the camera matrix orbiting around the origin
// at radius of 3.5 with elevation between 15 and 90 degrees
camera_matrix.Set(
CamMatrixf::Orbiting(
Vec3f(),
5.0,
Degrees(time * 11),
Degrees(15 + (-SineWave(0.25+time/12.5)+1.0)*0.5*75)
)
);
ModelMatrixf identity;
// make the model transformation matrix
ModelMatrixf model =
ModelMatrixf::Translation(0.0f, 1.5f, 0.0) *
ModelMatrixf::RotationZ(Degrees(time * 43))*
ModelMatrixf::RotationY(Degrees(time * 63))*
ModelMatrixf::RotationX(Degrees(time * 79));
// make the reflection matrix
auto reflection = ModelMatrixf::Reflection(false, true, false);
//
gl.Disable(Capability::Blend);
gl.Disable(Capability::DepthTest);
gl.Enable(Capability::StencilTest);
gl.ColorMask(false, false, false, false);
gl.StencilFunc(CompareFunction::Always, 1, 1);
gl.StencilOp(StencilOp::Keep, StencilOp::Keep, StencilOp::Replace);
gl.Bind(plane);
model_matrix.Set(identity);
gl.DrawArrays(PrimitiveType::TriangleStrip, 0, 4);
gl.ColorMask(true, true, true, true);
gl.Enable(Capability::DepthTest);
gl.StencilFunc(CompareFunction::Equal, 1, 1);
gl.StencilOp(StencilOp::Keep, StencilOp::Keep, StencilOp::Keep);
// draw the cube using the reflection program
model_matrix.Set(reflection * model);
gl.Bind(cube);
cube_instr.Draw(cube_indices);
gl.Disable(Capability::StencilTest);
// draw the cube using the normal object program
model_matrix.Set(model);
cube_instr.Draw(cube_indices);
// blend-in the plane
gl.Enable(Capability::Blend);
gl.BlendEquation(BlendEquation::Max);
gl.Bind(plane);
model_matrix.Set(identity);
gl.DrawArrays(PrimitiveType::TriangleStrip, 0, 4);
}
示例2: Render
void GIDeferredRenderer::Render()
{
using namespace oglplus;
static Context gl;
static auto &camera = Camera::Active();
static auto &scene = Scene::Active();
static auto &info = Window().Info();
if (!camera || !scene || !scene->IsLoaded() || VoxelizerRenderer::ShowVoxels)
{
return;
}
SetAsActive();
// bind g buffer for writing
geometryBuffer.Bind(FramebufferTarget::Draw);
gl.ColorMask(true, true, true, true);
gl.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.Viewport(info.framebufferWidth, info.framebufferHeight);
gl.Clear().ColorBuffer().DepthBuffer();
// activate geometry pass shader program
CurrentProgram<GeometryProgram>(GeometryPass());
// rendering and GL flags
gl.ClearDepth(1.0f);
gl.Enable(Capability::DepthTest);
gl.Disable(Capability::Blend);
gl.Enable(Capability::CullFace);
gl.FrontFace(FaceOrientation::CCW);
gl.CullFace(Face::Back);
camera->DoFrustumCulling(true);
// draw whole scene tree from root node
scene->rootNode->DrawList();
// start light pass
DefaultFramebuffer().Bind(FramebufferTarget::Draw);
gl.ColorMask(true, true, true, true);
gl.Viewport(info.framebufferWidth, info.framebufferHeight);
gl.Clear().ColorBuffer().DepthBuffer();
CurrentProgram<LightingProgram>(LightingPass());
// pass light info and texture locations for final light pass
SetLightPassUniforms();
// draw the result onto a fullscreen quad
fsQuad.DrawElements();
}
示例3: Render
void Render(double time) {
gl.Clear().ColorBuffer().DepthBuffer().StencilBuffer();
auto camera = CamMatrixf::Orbiting(
Vec3f(),
9.0,
FullCircles(time * 0.1),
Degrees(15 + (-SineWave(0.25 + time / 12.5) + 1.0) * 0.5 * 75));
ModelMatrixf identity;
ModelMatrixf model =
ModelMatrixf::Translation(0.0f, 2.5f, 0.0) *
ModelMatrixf::RotationA(
Vec3f(1.0f, 1.0f, 1.0f), FullCircles(time * 0.2));
gl.CullFace(Face::Back);
gl.ColorMask(true, true, true, true);
gl.DepthMask(true);
gl.Disable(Capability::StencilTest);
object_prog.Use();
object_camera_matrix.Set(camera);
object_light_mult.Set(0.2f);
object_model_matrix.Set(identity);
plane.Bind();
gl.DrawArrays(PrimitiveType::TriangleStrip, 0, 4);
object_model_matrix.Set(model);
torus.Bind();
torus_instr.Draw(torus_indices);
gl.ColorMask(false, false, false, false);
gl.DepthMask(false);
gl.Enable(Capability::StencilTest);
gl.StencilFunc(CompareFunction::Always, 0);
gl.StencilOpSeparate(
Face::Front, StencilOp::Keep, StencilOp::Keep, StencilOp::Incr);
gl.StencilOpSeparate(
Face::Back, StencilOp::Keep, StencilOp::Keep, StencilOp::Decr);
shadow_prog.Use();
shadow_camera_matrix.Set(camera);
shadow_model_matrix.Set(model);
gl.CullFace(Face::Back);
torus_instr.Draw(torus_indices);
gl.CullFace(Face::Front);
torus_instr.Draw(torus_indices);
gl.CullFace(Face::Back);
gl.ColorMask(true, true, true, true);
gl.DepthMask(true);
gl.Clear().DepthBuffer();
gl.StencilFunc(CompareFunction::Equal, 0);
gl.StencilOp(StencilOp::Keep, StencilOp::Keep, StencilOp::Keep);
object_prog.Use();
object_light_mult.Set(2.5);
object_model_matrix.Set(identity);
object_color.Set(0.8f, 0.7f, 0.4f);
plane.Bind();
gl.DrawArrays(PrimitiveType::TriangleStrip, 0, 4);
object_model_matrix.Set(model);
object_color.Set(0.9f, 0.8f, 0.1f);
torus.Bind();
torus_instr.Draw(torus_indices);
}
示例4: RenderImage
void RenderImage(
double time,
const Mat4f& torus_matrix,
const Mat4f& light_proj_matrix
)
{
// this is going into the on-screen framebuffer
DefaultFramebuffer().Bind(Framebuffer::Target::Draw);
gl.ClearColor(1.0f, 0.9f, 0.8f, 0.0f);
gl.Viewport(width, height);
gl.Clear().ColorBuffer().DepthBuffer();
gl.CullFace(Face::Back);
//
transf_prog.light_proj_matrix.Set(light_proj_matrix);
Mat4f perspective = CamMatrixf::PerspectiveX(
Degrees(60),
float(width)/height,
1, 60
);
// setup the camera
Vec3f camera_target(0.0f, 0.8f, 0.0f);
auto camera = CamMatrixf::Orbiting(
camera_target,
GLfloat(7.0 - SineWave(time / 14.0)*3.0),
FullCircles(time / 26.0),
Degrees(45 + SineWave(time / 17.0) * 40)
);
Vec3f camera_position = camera.Position();
transf_prog.camera_matrix.Set(perspective*camera);
transf_prog.camera_position.Set(camera_position);
// render into the depth buffer
shadow_pp.Bind();
gl.Enable(Capability::PolygonOffsetFill);
gl.ColorMask(false, false, false, false);
transf_prog.model_matrix = ModelMatrixf();
plane.Draw();
transf_prog.model_matrix.Set(torus_matrix);
torus.Draw();
gl.ColorMask(true, true, true, true);
gl.Disable(Capability::PolygonOffsetFill);
gl.Enable(Capability::Blend);
gl.Disable(Capability::Blend);
// render into the color buffer
sketch_pp.Bind();
gl.Enable(Capability::Blend);
transf_prog.model_matrix = ModelMatrixf();
transf_prog.texture_matrix.Set(Mat2f(Vec2f(3.0, 0.0), Vec2f(0.0, 3.0)));
plane.Draw();
transf_prog.model_matrix.Set(torus_matrix);
transf_prog.texture_matrix.Set(Mat2f(Vec2f(8.0, 0.0), Vec2f(0.0, 2.0)));
torus.Draw([](GLuint phase) -> bool { return phase < 4; });
transf_prog.texture_matrix.Set(Mat2f(Vec2f(0.0, 2.0), Vec2f(8.0, 0.0)));
torus.Draw([](GLuint phase) -> bool { return phase >= 4; });
// render the edges
line_pp.Bind();
transf_prog.model_matrix = ModelMatrixf();
plane.DrawEdges();
transf_prog.model_matrix.Set(torus_matrix);
torus.DrawEdges();
gl.Disable(Capability::Blend);
}