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


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

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


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

示例1: BSP

	void BSP(const Mat4f& camera, std::size_t p)
	{
		assert(p < std::size_t(plane.size()));
		// the normal vector of the plane
		Vec4f normal(make_plane[p].Normal(), 0.0);
		// check if we are seeing the front or the back face
		GLfloat sign = ((camera*normal).z() >= 0.0f)? 1.0f: -1.0f;
		bool at_leaf = p+1 == plane.size();

		gl.Enable(Functionality::ClipDistance, p);
		torus_clip_signs[p].Set(-sign);
		plane_clip_signs[p].Set(-sign);
		if(at_leaf) RenderTorus();
		else BSP(camera, p+1);
		gl.Disable(Functionality::ClipDistance, p);

		RenderPlane(p);

		gl.Enable(Functionality::ClipDistance, p);
		torus_clip_signs[p].Set(+sign);
		plane_clip_signs[p].Set(+sign);
		if(at_leaf) RenderTorus();
		else BSP(camera, p+1);
		gl.Disable(Functionality::ClipDistance, p);

	}
开发者ID:detunized,项目名称:oglplus,代码行数:26,代码来源:022_xyz_planes.cpp

示例2: RenderGlassShadowMap

	void RenderGlassShadowMap(
		const Vec3f& light_position,
		const Vec3f& torus_center,
		const Mat4f& torus_matrix,
		const Mat4f& light_proj_matrix
	)
	{
		glass_shadow_fbo.Bind(Framebuffer::Target::Draw);

		gl.Viewport(shadow_tex_side, shadow_tex_side);
		const GLfloat clear_color[4] = {1.0f, 1.0f, 1.0f, 0.0f};
		gl.ClearColorBuffer(0, clear_color);

		transf_prog.camera_matrix.Set(light_proj_matrix);
		transf_prog.camera_position.Set(light_position);
		transf_prog.light_proj_matrix.Set(light_proj_matrix);
		transf_prog.light_position.Set(light_position);

		// Render the torus' frame
		transf_prog.model_matrix.Set(torus_matrix);

		// setup the view clipping plane
		Planef clip_plane = Planef::FromPointAndNormal(
			torus_center,
			Normalized(light_position-torus_center)
		);
		transf_prog.clip_plane.Set(clip_plane.Equation());

		light_pp.Bind();

		light_prog.color = Vec3f(0.6f, 0.4f, 0.1f);

		gl.Disable(Capability::DepthTest);
		gl.Enable(Functionality::ClipDistance, 0);
		gl.Enable(Capability::Blend);

		for(int c=0; c!=2; ++c)
		{
			transf_prog.clip_direction.Set((c == 0)?1:-1);

			for(int p=3; p>=0; --p)
			{
				if(p % 2 == 0) gl.CullFace(Face::Front);
				else gl.CullFace(Face::Back);
				torus.Draw(
					[&p](GLuint phase) -> bool
					{
						if(p == 0 || p == 3)
						{
							return (phase == 4);
						}
						else return (phase > 4);
					}
				);
			}
		}
		gl.Disable(Capability::Blend);
		gl.Disable(Functionality::ClipDistance, 0);
		gl.Enable(Capability::DepthTest);
	}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:60,代码来源:033_metal_and_glass.cpp

示例3: 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);
	}
开发者ID:Extrunder,项目名称:oglplus,代码行数:57,代码来源:023_reflected_cube.cpp

示例4: Render

	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();

		CamMatrixf camera = CamMatrixf::Orbiting(
			Vec3f(),
			4.5f + float(SineWave(time / 25.0)),
			FullCircles(time / 30.0),
			Degrees(SineWave(time / 19.0) * 20)
		);
		light_prog.camera_matrix.Set(camera);
		flare_prog.camera_matrix.Set(camera);
		shape_prog.camera_matrix.Set(camera);
		shape_prog.camera_position.Set(camera.Position());

		shape_prog.model_matrix.Set(
			ModelMatrixf::RotationX(FullCircles(time / 30.0))
		);

		shape_prog.Use();
		shape.Draw();
		NoProgram().Use();

		lights.Bind();

		light_prog.Use();

		for(GLuint l=0; l!=n_flares; ++l)
		{
			queries[l].Begin(Query::Target::SamplesPassed);
			gl.DrawArrays(PrimitiveType::Points, l, 1);
			queries[l].End(Query::Target::SamplesPassed);
		}

		gl.Enable(Capability::Blend);
		gl.Disable(Capability::DepthTest);
		flare_prog.Use();
		for(GLuint l=0; l!=n_flares; ++l)
		{
			GLint samples = 0;
			queries[l].WaitForResult(samples);
			if(samples != 0)
			{
				flare_prog.samples = samples;
				gl.DrawArrays(PrimitiveType::Points, l, 1);
			}
		}
		gl.Enable(Capability::DepthTest);
		gl.Disable(Capability::Blend);
	}
开发者ID:xubingyue,项目名称:oglplus,代码行数:50,代码来源:029_flares.cpp

示例5: FinishBatch

void SpectraDefaultGPUMatrixTransf::FinishBatch(void)
{
	using namespace oglplus;
	Context gl;
	gl.Disable(Capability::RasterizerDiscard);
	VertexArray::Unbind();
}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:7,代码来源:calculator_gpu.cpp

示例6: BlurShadowMap

void ShadowMapRenderer::BlurShadowMap()
{
    using namespace oglplus;
    static Context gl;
    auto &prog = BlurShader();
    CurrentProgram<BlurProgram>(prog);
    // horizontal blur
    blurFramebuffer.Bind(FramebufferTarget::Draw);
    gl.Disable(Capability::DepthTest);
    // active shadow to be read
    shadowMap.Active(0);
    shadowMap.Bind(TextureTarget::_2D);
    // update uniform
    prog.source.Set(0);
    prog.blurDirection.Set(glm::vec2(1.0f / shadowMapSize.x * blurScale, 0.0f));
    prog.blurType.Set(blurQuality);
    gl.Clear().DepthBuffer().ColorBuffer();
    fsQuad.DrawElements();
    // blur vertically
    shadowFramebuffer.Bind(FramebufferTarget::Draw);
    // active shadow to be read
    blurShadow.Bind(TextureTarget::_2D);
    // update uniform
    prog.source.Set(0);
    prog.blurDirection.Set(glm::vec2(0.0f, 1.0f / shadowMapSize.y * blurScale));
    prog.blurType.Set(blurQuality);
    gl.Clear().DepthBuffer().ColorBuffer();
    fsQuad.DrawElements();
    gl.Enable(Capability::DepthTest);
}
开发者ID:Alan-Baylis,项目名称:VCTRenderer,代码行数:30,代码来源:shadow_map_renderer.cpp

示例7: RenderFrameShadowMap

	void RenderFrameShadowMap(
		const Vec3f& light_position,
		const Mat4f& torus_matrix,
		const Mat4f& light_proj_matrix
	)
	{
		frame_shadow_fbo.Bind(Framebuffer::Target::Draw);

		gl.Viewport(shadow_tex_side, shadow_tex_side);
		gl.ClearDepthBuffer(1.0f);
		gl.CullFace(Face::Back);

		transf_prog.camera_matrix.Set(light_proj_matrix);
		transf_prog.camera_position.Set(light_position);

		// Render the torus' frame
		transf_prog.model_matrix.Set(torus_matrix);

		shadow_pp.Bind();

		gl.Enable(Capability::PolygonOffsetFill);
		torus.Draw(
			[](GLuint phase) -> bool
			{
				return (phase <= 3);
			}
		);
		gl.Disable(Capability::PolygonOffsetFill);
	}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:29,代码来源:033_metal_and_glass.cpp

示例8: Render

	void Render(double time)
	{
		static const Mat4f reflection(
			Vec4f( 1.0, 0.0, 0.0, 0.0),
			Vec4f( 0.0,-1.0, 0.0, 0.0),
			Vec4f( 0.0, 0.0, 1.0, 0.0),
			Vec4f( 0.0, 0.0, 0.0, 1.0)
		);

		auto camera = CamMatrixf::Orbiting(
			Vec3f(),
			GLfloat(7.0 + SineWave(time / 12.0)*2.5),
			FullCircles(time / 10.0),
			Degrees(45.0 - SineWave(time / 7.0)*35.0)
		);

		shape_prog.Use();
		shape.Bind();

		gl.Enable(Capability::CullFace);
		gl.FrontFace(make_shape.FaceWinding());

		// render into the off-screen framebuffer
		fbo.Bind(Framebuffer::Target::Draw);
		gl.Viewport(
			(width - refl_tex_side) / 2,
			(height - refl_tex_side) / 2,
			refl_tex_side, refl_tex_side
		);
		gl.Clear().ColorBuffer().DepthBuffer();

		shape_camera_matrix.Set(
			camera *
			ModelMatrixf::Translation(0.0f, -1.0f, 0.0f) *
			reflection
		);

		gl.CullFace(Face::Front);
		shape_instr.Draw(shape_indices);

		gl.Bind(Framebuffer::Target::Draw, DefaultFramebuffer());
		gl.Viewport(width, height);
		gl.Clear().ColorBuffer().DepthBuffer();

		shape_camera_matrix.Set(camera);

		gl.CullFace(Face::Back);
		shape_instr.Draw(shape_indices);

		gl.Disable(Capability::CullFace);

		// Render the plane
		plane_prog.Use();
		plane.Bind();

		plane_camera_matrix.Set(camera);
		plane_camera_position.Set(camera.Position());

		plane_instr.Draw(plane_indices);
	}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:60,代码来源:030_pool_tiles.cpp

示例9: 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

示例10: operator

	void operator()(const Particles& particles)
	{
		gl.Enable(Capability::Blend);
		gl.Bind(vao);
		gl.Use(prog);
		gl.DrawElements(PrimitiveType::Points, particles.Count(), (GLuint*)0);
		gl.Disable(Capability::Blend);
	}
开发者ID:Extrunder,项目名称:oglplus,代码行数:8,代码来源:029_gpu_sort_tfb.cpp

示例11: RenderPlane

	void RenderPlane(std::size_t p)
	{
		gl.Enable(Capability::Blend);
		plane_prog.Use();
		plane_normal.Set(make_plane[p].Normal());
		plane[p].Bind();
		plane_instr.Draw(plane_indices);
		gl.Disable(Capability::Blend);
	}
开发者ID:detunized,项目名称:oglplus,代码行数:9,代码来源:022_xyz_planes.cpp

示例12: ParallaxMapExample

    ParallaxMapExample()
      : prog(make())
      , projection_matrix(prog, "ProjectionMatrix")
      , camera_matrix(prog, "CameraMatrix")
      , model_matrix(prog, "ModelMatrix")
      , camera_position(prog, "CameraPosition")
      , light_position(prog, "LightPosition")
      , shape(
          List("Position")("Normal")("Tangent")("TexCoord").Get(),
          shapes::Torus(1.0f, 0.5, 72, 48)) {
        shape.UseInProgram(prog);

        auto tex_image = images::LoadTexture("bricks_color_hmap");

        Texture::Active(0);
        try {
            UniformSampler(prog, "ColorMap").Set(0);
            gl.Bound(Texture::Target::_2D, color_tex)
              .MinFilter(TextureMinFilter::LinearMipmapLinear)
              .MagFilter(TextureMagFilter::Linear)
              .WrapS(TextureWrap::Repeat)
              .WrapT(TextureWrap::Repeat)
              .Image2D(tex_image)
              .GenerateMipmap();
        } catch(Error&) {
        }

        Texture::Active(1);
        try {
            UniformSampler(prog, "BumpMap").Set(1);
            gl.Bound(Texture::Target::_2D, bump_tex)
              .MinFilter(TextureMinFilter::LinearMipmapLinear)
              .MagFilter(TextureMagFilter::Linear)
              .WrapS(TextureWrap::Repeat)
              .WrapT(TextureWrap::Repeat)
              .Image2D(
                images::NormalMap(tex_image, images::NormalMap::FromAlpha()))
              .GenerateMipmap();
        } catch(Error&) {
        }

        gl.ClearColor(0.1f, 0.1f, 0.1f, 0.0f);
        gl.ClearDepth(1.0f);
        gl.Enable(Capability::DepthTest);
        gl.Disable(Capability::CullFace);

        gl.Enable(Functionality::ClipDistance, 0);
        gl.Enable(Functionality::ClipDistance, 1);
        gl.Enable(Functionality::ClipDistance, 2);
    }
开发者ID:matus-chochlik,项目名称:oglplus,代码行数:50,代码来源:031_brick_torus.cpp

示例13: 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);
	}
开发者ID:Extrunder,项目名称:oglplus,代码行数:46,代码来源:030_pin_display.cpp

示例14: 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();
}
开发者ID:Alan-Baylis,项目名称:VCTRenderer,代码行数:43,代码来源:gi_deferred_renderer.cpp

示例15: Render

	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();

		auto camera = CamMatrixf::Orbiting(
			Vec3f(),
			8.5,
			FullCircles(time / 5.0),
			Degrees(15 + (-SineWave(time/10.0)+1.0)* 0.5 * 75)
		);
		ModelMatrixf model =
			ModelMatrixf::Translation(0.0f, 2.5f, 0.0) *
			ModelMatrixf::RotationA(
				Vec3f(1.0f, 1.0f, 1.0f),
				FullCircles(time / 7.0)
			);

		plane_prog.Use();
		plane_camera_matrix.Set(camera);

		plane.Bind();
		gl.DrawArrays(PrimitiveType::TriangleStrip, 0, 4);

		shape_prog.Use();
		shape_camera_matrix.Set(camera);

		shape_model_matrix.Set(model);
		shape.Bind();
		shape_instr.Draw(shape_indices);

		halo_prog.Use();
		halo_camera_matrix.Set(camera);
		halo_model_matrix.Set(model);

		gl.DepthMask(false);
		gl.Enable(Capability::Blend);
		shape_instr.Draw(shape_indices);
		gl.Disable(Capability::Blend);
		gl.DepthMask(true);
	}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:40,代码来源:026_shape_halo.cpp


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