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


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

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


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

示例1: gl

	DSATextureExample(int /*argc*/, const char** /*argv*/)
	 : gl()
	 , prog(make_prog())
	 , projection_matrix(prog, "ProjectionMatrix")
	 , camera_matrix(prog, "CameraMatrix")
	 , model_matrix(prog, "ModelMatrix")
	 , textured_cube(
		oglplus::List("Position")("Normal")("TexCoord").Get(),
		oglplus::shapes::Cube(),
		prog
	)
	{
		using namespace oglplus;

		checker.target = Texture::Target::_2D;
		checker.Image2D(images::CheckerRedBlack(256, 256, 8, 8));
		checker.GenerateMipmap();
		checker.MinFilter(TextureMinFilter::LinearMipmapLinear);
		checker.MagFilter(TextureMagFilter::Linear);
		checker.Anisotropy(2.0);
		checker.WrapS(TextureWrap::Repeat);
		checker.WrapT(TextureWrap::Repeat);
		checker.Bind();
		(prog/"Checker") = 0;
		(prog/"LightPos") = Vec3f(10.0f, 20.0f, 30.0f);

		gl.ClearColor(0.3f, 0.3f, 0.3f, 0.0f);
		gl.ClearDepth(1.0f);
		gl.Enable(Capability::DepthTest);
		gl.Enable(Capability::CullFace);
	}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:31,代码来源:003_dsa_texture.cpp

示例2: attr


//.........这里部分代码省略.........
			"		 ct, 0.0,  st, 0.0,"
			"		0.0, 1.0, 0.0, 0.0,"
			"		-st, 0.0,  ct, 0.0,"
			"		0.0, 0.0, 0.0, 1.0 "
			"	) * mat4("
			"		 1.0, 0.0, 0.0, 0.0,"
			"		 0.0, 1.0, 0.0, 0.0,"
			"		 0.0, 0.0, 1.0, 0.0,"
			"		12.0, 0.0, 0.0, 1.0 "
			"	) * mat4("
			"		 ct, -st, 0.0, 0.0,"
			"		 st,  ct, 0.0, 0.0,"
			"		0.0, 0.0, 1.0, 0.0,"
			"		0.0, 0.0, 0.0, 1.0 "
			"	);"
			"	gl_Position = "
			"		ModelMatrix *"
			"		ScaleMatrix *"
			"		Position;"

			"	vec3 vertLightDir = normalize(LightPos - gl_Position.xyz);"
			"	vec3 vertNormal = normalize(("
			"		ModelMatrix *"
			"		vec4(Normal, 0.0)"
			"	).xyz);"

			"	gl_Position = CameraMatrix * gl_Position;"

			"	vertColor = abs(normalize("
			"		Normal -"
			"		vec3(1.0, 1.0, 1.0) +"
			"		Position.xyz*0.2"
			"	)) * (0.6 + 0.5*max(dot(vertNormal, vertLightDir), 0.0));"
			"}"
		);
		// compile it
		vs.Compile();

		// set the fragment shader source
		fs.Source(
			"#version 330\n"
			"in vec3 vertColor;"
			"out vec3 fragColor;"
			"void main(void)"
			"{"
			"	fragColor = vertColor;"
			"}"
		);
		// compile it
		fs.Compile();

		// attach the shaders to the program
		prog.AttachShader(vs);
		prog.AttachShader(fs);
		// link and use it
		prog.Link();
		prog.Use();

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

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

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

		//
		gl.ClearColor(0.8f, 0.8f, 0.8f, 0.0f);
		gl.ClearDepth(1.0f);
		gl.Enable(oglplus::Capability::DepthTest);

		oglplus::Uniform<oglplus::Vec3f>(prog, "LightPos").Set(
			glm::vec3(7.0, 3.0, -1.0)
		);

		oglplus::Uniform<oglplus::Mat4f>(prog, "ScaleMatrix").Set(
			glm::scale(glm::mat4(1.0), glm::vec3(1.0, 0.3, 1.7))
		);
	}
开发者ID:pm990320,项目名称:OpenGLLearning,代码行数:101,代码来源:007_glm_boxes.cpp

示例3: input


//.........这里部分代码省略.........
						// get the poly block pointer
						auto poly_ptr = object_data_data.TryGet<void*>("mpoly", nullptr);
						// and the loop block pointer
						auto loop_ptr = object_data_data.TryGet<void*>("mloop", nullptr);
						// open the poly and loop blocks (if we have both)
						if(poly_ptr && loop_ptr)
						{
							auto poly_data = blend_file[poly_ptr];
							auto loop_data = blend_file[loop_ptr];
							// get the number of polys in the block
							std::size_t n_polys = poly_data.BlockElementCount();
							// get the fields of poly and loop
							auto poly_loopstart_field = poly_data.Field<int>("loopstart");
							auto poly_totloop_field = poly_data.Field<int>("totloop");
							auto loop_v_field = loop_data.Field<int>("v");

							// make a vector of index data
							std::vector<GLuint> is;
							for(std::size_t f=0; f!=n_polys; ++f)
							{
								int ls = poly_loopstart_field.Get(f);
								int tl = poly_totloop_field.Get(f);

								for(int l=0; l!=tl; ++l)
								{
									int v = loop_v_field.Get(ls+l);
									is.push_back(v+index_offset);
								}
								is.push_back(0); // primitive restart index
							}
							// append the values
							idx_data.insert(idx_data.end(), is.begin(), is.end());
						}
						index_offset += n_verts;
					}
				}
			}
			catch(...)
			{ }
			// and get the pointer to the nex block
			object_link_ptr = object_link_data.Field<void*>("next").Get();
		}

		meshes.Bind();

		positions.Bind(Buffer::Target::Array);
		{
			Buffer::Data(Buffer::Target::Array, pos_data);
			VertexAttribArray attr(prog, "Position");
			attr.Setup<GLfloat>(3);
			attr.Enable();
		}

		normals.Bind(Buffer::Target::Array);
		{
			Buffer::Data(Buffer::Target::Array, nml_data);
			VertexAttribArray attr(prog, "Normal");
			attr.Setup<GLfloat>(3);
			attr.Enable();
		}

		indices.Bind(Buffer::Target::ElementArray);
		Buffer::Data(Buffer::Target::ElementArray, idx_data);

		element_count = idx_data.size();

		// find the extremes of the mesh(es)
		GLfloat min_x = pos_data[3], max_x = pos_data[3];
		GLfloat min_y = pos_data[4], max_y = pos_data[4];
		GLfloat min_z = pos_data[5], max_z = pos_data[5];
		for(std::size_t v=1, vn=pos_data.size()/3; v!=vn; ++v)
		{
			GLfloat x = pos_data[v*3+0];
			GLfloat y = pos_data[v*3+1];
			GLfloat z = pos_data[v*3+2];

			if(min_x > x) min_x = x;
			if(min_y > y) min_y = y;
			if(min_z > z) min_z = z;
			if(max_x < x) max_x = x;
			if(max_y < y) max_y = y;
			if(max_z < z) max_z = z;
		}

		// position the camera target
		camera_target = Vec3f(
			(min_x + max_x) * 0.5,
			(min_y + max_y) * 0.5,
			(min_z + max_z) * 0.5
		);
		// and calculate a good value for camera distance
		camera_distance = 1.1*Distance(camera_target, Vec3f(min_x, min_y, min_z))+1.0;


		gl.ClearColor(0.17f, 0.22f, 0.17f, 0.0f);
		gl.ClearDepth(1.0f);
		gl.Enable(Capability::DepthTest);
		gl.Enable(Capability::PrimitiveRestart);

	}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:101,代码来源:026_blender_mesh_loader.cpp


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