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


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

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


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

示例1: attr


//.........这里部分代码省略.........
			"out vec4 fragColor;"
			"void main(void)"
			"{"
			"	fragColor = vec4("
			"		0.5, 0.4, 0.3,"
			"		pow(geomAlpha, 2.0)"
			"	);"
			"}"
		);
		fs_halo.Compile();

		halo_prog.AttachShader(vs_halo);
		halo_prog.AttachShader(gs_halo);
		halo_prog.AttachShader(fs_halo);
		halo_prog.Link();

		// bind the VAO for the shape
		shape.Bind();

		// bind the VBO for the shape vertices
		shape_verts.Bind(Buffer::Target::Array);
		{
			std::vector<GLfloat> data;
			GLuint n_per_vertex = make_shape.Positions(data);
			Buffer::Data(Buffer::Target::Array, data);

			VertexAttribSlot location;
			if(VertexArrayAttrib::QueryCommonLocation(
				MakeGroup(shape_prog, halo_prog),
				"Position",
				location
			))
			{
				VertexArrayAttrib attr(location);
				attr.Setup<GLfloat>(n_per_vertex);
				attr.Enable();
			}
			else OGLPLUS_ABORT("Inconsistent 'Position' location");
		}

		// bind the VBO for the shape normals
		shape_normals.Bind(Buffer::Target::Array);
		{
			std::vector<GLfloat> data;
			GLuint n_per_vertex = make_shape.Normals(data);
			Buffer::Data(Buffer::Target::Array, data);

			shape_prog.Use();
			VertexArrayAttrib attr(shape_prog, "Normal");
			attr.Setup<GLfloat>(n_per_vertex);
			attr.Enable();
		}

		// bind the VAO for the plane
		plane.Bind();

		// bind the VBO for the plane vertices
		plane_verts.Bind(Buffer::Target::Array);
		{
			GLfloat data[4*3] = {
				-9.0f, 0.0f,  9.0f,
				-9.0f, 0.0f, -9.0f,
				 9.0f, 0.0f,  9.0f,
				 9.0f, 0.0f, -9.0f
			};
			Buffer::Data(Buffer::Target::Array, 4*3, data);
			plane_prog.Use();
			VertexArrayAttrib attr(plane_prog, "Position");
			attr.Setup<Vec3f>();
			attr.Enable();
		}

		// bind the VBO for the plane normals
		plane_normals.Bind(Buffer::Target::Array);
		{
			GLfloat data[4*3] = {
				-0.1f, 1.0f,  0.1f,
				-0.1f, 1.0f, -0.1f,
				 0.1f, 1.0f,  0.1f,
				 0.1f, 1.0f, -0.1f
			};
			Buffer::Data(Buffer::Target::Array, 4*3, data);
			plane_prog.Use();
			VertexArrayAttrib attr(plane_prog, "Normal");
			attr.Setup<Vec3f>();
			attr.Enable();
		}

		Vec3f lightPos(2.0f, 2.5f, 9.0f);

		ProgramUniform<Vec3f>(shape_prog, "LightPos").Set(lightPos);
		ProgramUniform<Vec3f>(plane_prog, "LightPos").Set(lightPos);

		gl.ClearColor(0.2f, 0.2f, 0.2f, 0.0f);
		gl.ClearDepth(1.0f);
		gl.ClearStencil(0);

		gl.Enable(Capability::DepthTest);
		gl.BlendFunc(BlendFn::SrcAlpha, BlendFn::One);
	}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:101,代码来源:026_shape_halo.cpp

示例2: attr


//.........这里部分代码省略.........
          "}");
        fs_shadow.Compile();

        shadow_prog.AttachShader(vs_shadow);
        shadow_prog.AttachShader(gs_shadow);
        shadow_prog.AttachShader(fs_shadow);
        shadow_prog.Link().Use();

        shadow_projection_matrix.BindTo("ProjectionMatrix");
        shadow_camera_matrix.BindTo("CameraMatrix");
        shadow_model_matrix.BindTo("ModelMatrix");

        // bind the VAO for the torus
        torus.Bind();

        // bind the VBO for the torus vertices
        torus_verts.Bind(Buffer::Target::Array);
        {
            std::vector<GLfloat> data;
            GLuint n_per_vertex = make_torus.Positions(data);
            Buffer::Data(Buffer::Target::Array, data);

            VertexArrayAttrib attr(VertexArrayAttrib::GetCommonLocation(
              MakeGroup(object_prog, shadow_prog), "Position"));
            attr.Setup<GLfloat>(n_per_vertex);
            attr.Enable();
        }

        // bind the VBO for the torus normals
        torus_normals.Bind(Buffer::Target::Array);
        {
            std::vector<GLfloat> data;
            GLuint n_per_vertex = make_torus.Normals(data);
            Buffer::Data(Buffer::Target::Array, data);

            object_prog.Use();
            VertexArrayAttrib attr(object_prog, "Normal");
            attr.Setup<GLfloat>(n_per_vertex);
            attr.Enable();
        }
        // bind the VAO for the plane
        plane.Bind();

        // bind the VBO for the plane vertices
        plane_verts.Bind(Buffer::Target::Array);
        {
            GLfloat data[4 * 3] = {-9.0f,
                                   0.0f,
                                   -9.0f,
                                   -9.0f,
                                   0.0f,
                                   9.0f,
                                   9.0f,
                                   0.0f,
                                   -9.0f,
                                   9.0f,
                                   0.0f,
                                   9.0f};
            Buffer::Data(Buffer::Target::Array, 4 * 3, data);
            object_prog.Use();
            VertexArrayAttrib attr(object_prog, "Position");
            attr.Setup<GLfloat>(3);
            attr.Enable();
        }

        // bind the VBO for the torus normals
        plane_normals.Bind(Buffer::Target::Array);
        {
            GLfloat data[4 * 3] = {-0.1f,
                                   1.0f,
                                   0.1f,
                                   -0.1f,
                                   1.0f,
                                   -0.1f,
                                   0.1f,
                                   1.0f,
                                   0.1f,
                                   0.1f,
                                   1.0f,
                                   -0.1f};
            Buffer::Data(Buffer::Target::Array, 4 * 3, data);
            object_prog.Use();
            VertexArrayAttrib attr(object_prog, "Normal");
            attr.Setup<GLfloat>(3);
            attr.Enable();
        }

        Vec3f lightPos(2.0f, 9.0f, 3.0f);

        ProgramUniform<Vec3f>(object_prog, "LightPos").Set(lightPos);
        ProgramUniform<Vec3f>(shadow_prog, "LightPos").Set(lightPos);

        gl.ClearColor(0.2f, 0.2f, 0.2f, 0.0f);
        gl.ClearDepth(1.0f);
        gl.ClearStencil(0);

        gl.Enable(Capability::DepthTest);
        gl.Enable(Capability::CullFace);
        gl.FrontFace(make_torus.FaceWinding());
    }
开发者ID:matus-chochlik,项目名称:oglplus,代码行数:101,代码来源:026_stencil_shadow.cpp

示例3: gl


//.........这里部分代码省略.........
		"  20.4365,-35.81021"
		"l -43.78946,-30.11675"
		"c -7.37799,-6.14328"
		"  -6.76172,-11.95465"
		"  -30.59946,-14.4867"
		"  -7.3681,-8.26173"
		"  -16.91998,-15.58704"
		"  -17.77179,-25.44079"
		"l 3.19111,-1.30899"
		"c 5.66966,8.17456"
		"  5.04135,19.14781"
		"  19.90453,26.63415"
		"  16.79016,-0.42901"
		"  33.48024,-8.77684"
		"  37.51318,-17.5806"
		"z"
		"m 100.47604,12.17096"
		"  -41.13754,47.8457"
		"  -1.28556,3.45416"
		"  19.69984,15.03817"
		"  3.00685,-2.61745"
		"  39.98919,-47.11398"
		"  0.20368,-2.96727"
		"c -5.20109,-4.99"
		"  -10.11474,-10.17304"
		"  -17.87754,-13.34188"
		"z"
		"m 17.21754,25.10098"
		"  -2.34127,0.98707"
		"  -32.55714,39.03611"
		"  -2.52598,2.98121"
		"  15.36908,11.51245"
		"  4.68518,0.47953"
		"  34.77739,-39.62667"
		"  -0.55381,-3.64243"
		"c -3.06075,-4.58721"
		"  -10.50061,-10.2548"
		"  -16.85345,-11.72727"
		"z"
		"m -72.86065,19.8761"
		"  -15.2679,3.0925"
		"c 26.57114,13.9239"
		"  43.79716,29.59996"
		"  65.69469,44.40557"
		"  31.09815,22.86624"
		"  63.72592,40.27978"
		"  100.34072,52.54386"
		"  -19.7004,-24.16603"
		"  -45.48586,-53.7133"
		"  -80.19406,-78.6645"
		"l -13.63751,16.18691"
		"  -7.41411,-0.0354"
		"z"
		"m -60.76927,125.44609"
		"  -8.79676,44.89633"
		"  92.36105,9.4532"
		"  3.89632,-45.39793"
		"z"
		);

		GLfloat font_scale = 48;

		text_glyphs.GlyphRange(
			PathNVFontTarget::Standard,
			"Sans",
			PathNVFontStyle::Bold,
			0, 128,
			PathNVMissingGlyph::Use,
			~0,
			font_scale
		);

		gl.ClearColor(1.0f, 1.0f, 1.0f, 1.0f);
		gl.ClearStencil(0);
		gl.StencilMask(~0);
		gl.StencilFunc(CompareFunction::NotEqual, 0, 0xFF);
		gl.StencilOp(
			StencilOperation::Keep,
			StencilOperation::Keep,
			StencilOperation::Zero
		);

		gl.Enable(Capability::StencilTest);

		gl.Viewport(tex_side, tex_side);
		dsa.ProjectionMatrix()
			.LoadIdentity()
			.Ortho(0, tex_side, 0, tex_side, -1, 1);

		GLfloat font_min_max[2];
		text_glyphs.GetMetricRange(
			PathNVMetricQuery::FontYMinBounds|
			PathNVMetricQuery::FontYMaxBounds,
			1, 0,
			font_min_max
		);
		font_y_min = font_min_max[0];
		font_y_max = font_min_max[1];
		font_height = font_y_max - font_y_min;
	}
开发者ID:Extrunder,项目名称:oglplus,代码行数:101,代码来源:026_nv_path_rendering.cpp

示例4: attr

	ReflectionExample(void)
	 : make_cube(0.5,0.5,0.5, 0.1,0.1,0.1, 3,3,3)
	 , cube_indices(make_cube.Indices())
	 , cube_instr(make_cube.Instructions())
	 , prog(make_prog())
	 , projection_matrix(prog, "ProjectionMatrix")
	 , camera_matrix(prog, "CameraMatrix")
	 , model_matrix(prog, "ModelMatrix")
	{
		gl.Use(prog);

		// bind the VAO for the cube
		gl.Bind(cube);

		// bind the VBO for the cube vertices
		gl.Bind(Buffer::Target::Array, cube_verts);
		{
			std::vector<GLfloat> data;
			GLuint n_per_vertex = make_cube.Positions(data);
			// upload the data
			Buffer::Data(Buffer::Target::Array, data);
			// setup the vertex attribs array for the vertices
			VertexArrayAttrib attr(prog, "Position");
			attr.Setup<GLfloat>(n_per_vertex);
			attr.Enable();
		}

		// bind the VBO for the cube normals
		gl.Bind(Buffer::Target::Array, cube_normals);
		{
			std::vector<GLfloat> data;
			GLuint n_per_vertex = make_cube.Normals(data);
			// upload the data
			Buffer::Data(Buffer::Target::Array, data);
			// setup the vertex attribs array for the normals
			VertexArrayAttrib attr(prog, "Normal");
			attr.Setup<GLfloat>(n_per_vertex);
			attr.Enable();
		}

		// bind the VAO for the plane
		gl.Bind(plane);

		// bind the VBO for the plane vertices
		gl.Bind(Buffer::Target::Array, plane_verts);
		{
			GLfloat data[4*3] = {
				-2.0f, 0.0f,  2.0f,
				-2.0f, 0.0f, -2.0f,
				 2.0f, 0.0f,  2.0f,
				 2.0f, 0.0f, -2.0f
			};
			// upload the data
			Buffer::Data(Buffer::Target::Array, 4*3, data);
			// setup the vertex attribs array for the vertices
			prog.Use();
			VertexArrayAttrib attr(prog, "Position");
			attr.Setup<Vec3f>();
			attr.Enable();
		}

		// bind the VBO for the cube normals
		gl.Bind(Buffer::Target::Array, plane_normals);
		{
			GLfloat data[4*3] = {
				-0.1f, 1.0f,  0.1f,
				-0.1f, 1.0f, -0.1f,
				 0.1f, 1.0f,  0.1f,
				 0.1f, 1.0f, -0.1f
			};
			// upload the data
			Buffer::Data(Buffer::Target::Array, 4*3, data);
			// setup the vertex attribs array for the normals
			prog.Use();
			VertexArrayAttrib attr(prog, "Normal");
			attr.Setup<Vec3f>();
			attr.Enable();
		}
		gl.Bind(NoVertexArray());

		Uniform<Vec3f>(prog, "LightPos").Set(1.5, 2.0, 2.5);
		//
		gl.ClearColor(0.2f, 0.2f, 0.2f, 0.0f);
		gl.ClearDepth(1.0f);
		gl.ClearStencil(0);
	}
开发者ID:Extrunder,项目名称:oglplus,代码行数:86,代码来源:023_reflected_cube.cpp


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