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


C++ LazyUniform::Set方法代码示例

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


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

示例1: Render

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

		int period = int(time * 0.125);
		if(prev_period < period)
		{
			if(period % 2)
				gl.PolygonMode(PolygonMode::Line);
			else gl.PolygonMode(PolygonMode::Fill);
			prev_period = period;
		}

		auto camera = CamMatrixf::Orbiting(
			Vec3f(0.0f, 2.0f, 0.0f),
			17.0f - CosineWave(time / 31.0f) * 10.0f,
			FullCircles(time / 43.0f),
			Degrees(45 - SineWave(time / 29.0f) * 35)
		);
		camera_matrix.Set(camera);
		camera_position.Set(camera.Position());

		anim_time.Set(time);

		plane_instr.Draw(plane_indices);
	}
开发者ID:detunized,项目名称:oglplus,代码行数:26,代码来源:023_waves.cpp

示例2: Render

	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// set the matrix for camera orbiting the origin
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				3.5,
				Degrees(time * 35),
				Degrees(SineWave(time / 20.0) * 60)
			)
		);
		// set the model matrix
		model_matrix.Set(
			ModelMatrixf::RotationY(FullCircles(time * 0.25)) *
			ModelMatrixf::RotationX(FullCircles(0.25))
		);

		gl.PolygonMode(PolygonMode::Line);
		gl.CullFace(Face::Front);
		torus_instr.Draw(torus_indices);
		//
		gl.PolygonMode(PolygonMode::Fill);
		gl.CullFace(Face::Back);
		torus_instr.Draw(torus_indices);
	}
开发者ID:detunized,项目名称:oglplus,代码行数:27,代码来源:016_cartoon_torus.cpp

示例3: Render

	void Render(double time)
	{
		const GLfloat clear_color[4] = {0.8f, 0.8f, 0.7f, 0.0f};
		gl.ClearColorBuffer(0, clear_color);
		gl.ClearDepthBuffer(1.0f);
		//
		// set the matrix for camera orbiting the origin
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				3.5,
				Degrees(time * 15),
				Degrees(SineWave(time / 6.3) * 45)
			)
		);
		model_matrix.Set(
			ModelMatrixf::Translation(-1.0, 0.0, 0.0) *
			ModelMatrixf::RotationZ(Degrees(time * 180))
		);
		cube_instr.Draw(cube_indices);
		model_matrix.Set(
			ModelMatrixf::Translation(+1.0, 0.0, 0.0) *
			ModelMatrixf::RotationY(Degrees(time * 90))
		);
		cube_instr.Draw(cube_indices);
	}
开发者ID:James-Z,项目名称:oglplus,代码行数:26,代码来源:013_striped_cubes.cpp

示例4: Render

	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// set the matrix for camera orbiting the origin
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				4.5 - SineWave(time / 16.0) * 2.0,
				FullCircles(time / 12.0),
				Degrees(SineWave(time / 30.0) * 90)
			)
		);

		// set the model matrix
		model_matrix.Set(
			ModelMatrixf::RotationA(
				Vec3f(1.0f, 1.0f, 1.0f),
				FullCircles(time / 10.0)
			)
		);

		shape.Bind();
		shape_instr.Draw(shape_indices);
	}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:25,代码来源:020_icosphere.cpp

示例5: Render

	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// set the matrix for camera orbiting the origin
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				4.0 - SineWave(time / 6.0) * 2.0,
				FullCircles(time * 0.4),
				Degrees(SineWave(time / 30.0) * 90)
			)
		);

		// set the model matrix
		model_matrix.Set(
			ModelMatrixf::RotationZ(FullCircles(time * 0.1))
		);

		cube.Bind();
		gl.CullFace(Face::Front);
		cube_instr.Draw(cube_indices);
		gl.CullFace(Face::Back);
		cube_instr.Draw(cube_indices);
	}
开发者ID:xdray,项目名称:oglplus,代码行数:25,代码来源:019_honeycomb_cube.cpp

示例6: Reshape

	void Reshape(GLuint width, GLuint height)
	{
		gl.Viewport(width, height);
		viewport_dimensions.Set(Vec2f(width, height));
		projection_matrix.Set(
			CamMatrixf::PerspectiveX(
				Degrees(60),
				double(width)/height,
				1, 40
			)
		);
	}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:12,代码来源:019_tessellation.cpp

示例7: Render

	void Render(double time)
	{
		// update the particle positions, ages and directions
		GLuint i = 0;
		float time_diff = (time - prev_time);
		float age_mult = 0.2f;
		while(i != positions.size())
		{
			float drag = 0.1f * (time_diff);
			if((ages[i] += time_diff * age_mult) < 1.0f)
			{
				directions[i] *= (1.0f - drag);
				positions[i] += directions[i]*time_diff;
			}
			else
			{
				ages[i] = 0.0f;
				directions[i] = NewDirection();
				positions[i] = Vec3f();
			}
			++i;
		}
		// if there are not enough particles yet
		if(i != particle_count)
		{
			float spawn_interval = 1.0f/(age_mult*particle_count);
			if(prev_spawn + spawn_interval < time)
			{
				directions.push_back(NewDirection());
				positions.push_back(Vec3f());
				ages.push_back(0.0f);
				prev_spawn = time;
			}
		}
		prev_time = time;

		assert(positions.size() == directions.size());
		assert(positions.size() == ages.size());

		// upload the particle positions
		pos_buf.Bind(Buffer::Target::Array);
		Buffer::Data(Buffer::Target::Array, positions);
		// upload the particle ages
		age_buf.Bind(Buffer::Target::Array);
		Buffer::Data(Buffer::Target::Array, ages);

		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// set the matrix for camera orbiting the origin
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				18.0f,
				FullCircles(time * 0.5),
				Degrees(45)
			)
		);

		gl.DrawArrays(PrimitiveType::Points, 0, positions.size());
	}
开发者ID:xdray,项目名称:oglplus,代码行数:60,代码来源:018_particle_system.cpp

示例8: Reshape

	void Reshape(GLuint width, GLuint height)
	{
		GLfloat w_2f = width / 2.0f;
		GLfloat h_2f = height/ 2.0f;
		GLfloat viewports[4*4] = {
			0.0f, 0.0f, w_2f, h_2f,
			w_2f, 0.0f, w_2f, h_2f,
			0.0f, h_2f, w_2f, h_2f,
			w_2f, h_2f, w_2f, h_2f
		};
		gl.ViewportArray(0, 4, viewports);

		projection = CamMatrixf::PerspectiveX(
			Degrees(65),
			double(width)/height,
			1, 30
		);

		camera_matrix_0.Set(
			projection *
			Mat4f(
				 Vec4f(0, 0,-1, 0),
				 Vec4f(0, 1, 0, 0),
				 Vec4f(1, 0, 0,-3),
				 Vec4f(0, 0, 0, 1)
			)
		);
		camera_matrix_1.Set(
			projection *
			Mat4f(
				 Vec4f(1, 0, 0, 0),
				 Vec4f(0, 0,-1, 0),
				 Vec4f(0, 1, 0,-3),
				 Vec4f(0, 0, 0, 1)
			)
		);
		camera_matrix_2.Set(
			projection *
			Mat4f(
				 Vec4f(1, 0, 0, 0),
				 Vec4f(0, 1, 0, 0),
				 Vec4f(0, 0, 1,-3),
				 Vec4f(0, 0, 0, 1)
			)
		);
	}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:46,代码来源:025_multi_viewport.cpp

示例9: Render

	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		auto camera = CamMatrixf::Orbiting(
			Vec3f(),
			4.5,
			Degrees(time * 35),
			Degrees(SineWave(time / 30.0) * 60)
		);

		auto model =
			ModelMatrixf::RotationY(FullCircles(time * 0.25)) *
			ModelMatrixf::RotationX(FullCircles(0.25));

		Vec4f lightPos(4.0f, 4.0f, -8.0f, 1.0f);

		prog.Use();
		camera_matrix.Set(camera);
		model_matrix.Set(model);
		light_pos_cam.Set(camera * lightPos);

		front_color.Set(Vec3f(0.3f, 0.2f, 0.0f));
		back_color.Set(Vec3f(0.2f, 0.1f, 0.0f));
		gl.PolygonMode(PolygonMode::Line);
		torus_instr.Draw(torus_indices);

		front_color.Set(Vec3f(0.9f, 0.8f, 0.1f));
		back_color.Set(Vec3f(1.0f, 0.9f, 0.8f));
		gl.PolygonMode(PolygonMode::Fill);
		torus_instr.Draw(torus_indices);
	}
开发者ID:xdray,项目名称:oglplus,代码行数:32,代码来源:023_lattice_torus.cpp

示例10: Render

	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// set the matrix for camera orbiting the origin
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(0.0f, 0.5f, 0.0f),
				6.5,
				Degrees(time * 35),
				Degrees(55 - SineWave(time / 20.0) * 30)
			)
		);
		light_pos.Set(light_path.Position(time / 10.0));

		plane.Bind();
		plane_instr.Draw(plane_indices);
	}
开发者ID:James-Z,项目名称:oglplus,代码行数:18,代码来源:018_newton_landscape.cpp

示例11: Render

	void Render(ExampleClock& clock)
	{
		positions.clear();
		ages.clear();

		// update the emitters and get the particle data
		for(auto i=emitters.begin(), e=emitters.end(); i!=e; ++i)
		{
			i->Update(clock);
			i->Upload(positions, ages);
		}
		assert(positions.size() == ages.size());

		// make a camera matrix
		auto cameraMatrix = CamMatrixf::Orbiting(
			Vec3f(),
			38.0 - SineWave(clock.Now().Seconds() / 6.0) * 17.0,
			FullCircles(clock.Now().Seconds() * 0.1),
			Degrees(SineWave(clock.Now().Seconds() / 20.0) * 60)
		);

		std::vector<float> depths(positions.size());
		std::vector<GLuint> indices(positions.size());
		// calculate the depths of the particles
		for(GLuint i=0, n=positions.size(); i!=n; ++i)
		{
			depths[i] = (cameraMatrix * Vec4f(positions[i], 1.0)).z();
			indices[i] = i;
		}

		// sort the indices by the depths
		std::sort(
			indices.begin(),
			indices.end(),
			[&depths](GLuint i, GLuint j)
			{
				return depths[i] < depths[j];
			}
		);

		// upload the particle positions
		pos_buf.Bind(Buffer::Target::Array);
		Buffer::Data(Buffer::Target::Array, positions, BufferUsage::DynamicDraw);
		// upload the particle ages
		age_buf.Bind(Buffer::Target::Array);
		Buffer::Data(Buffer::Target::Array, ages, BufferUsage::DynamicDraw);

		gl.Clear().ColorBuffer().DepthBuffer();
		camera_matrix.Set(cameraMatrix);
		// use the indices to draw the particles
		gl.DrawElements(
			PrimitiveType::Points,
			indices.size(),
			indices.data()
		);
	}
开发者ID:detunized,项目名称:oglplus,代码行数:56,代码来源:024_particle_trails.cpp

示例12: Render

	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		edge_width.Set(4.0+SineWave(time / 7.0)*3.0);

		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				5.5 - SineWave(time / 27)*2.0,
				Degrees(time * 33),
				Degrees(SineWave(time / 21.0) * 31)
			)
		);

		model_matrix.Set(ModelMatrixf::RotationZ(Degrees(time * 37)));

		shape_instr.Draw(shape_indices);
	}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:19,代码来源:017_single_pass_edges.cpp

示例13: Reshape

	void Reshape(GLuint width, GLuint height)
	{
		gl.Viewport(width, height);
		auto projection = CamMatrixf::PerspectiveX(
			Degrees(60),
			double(width)/height,
			1, 20
		);
		prog.Use();
		projection_matrix.Set(projection);
	}
开发者ID:xdray,项目名称:oglplus,代码行数:11,代码来源:023_lattice_torus.cpp

示例14: Reshape

	void Reshape(GLuint width, GLuint height)
	{
		gl.Viewport(width, height);
		projection_matrix.Set(
			CamMatrixf::PerspectiveX(
				Degrees(70),
				double(width)/height,
				1, 20
			)
		);
	}
开发者ID:GLDRorg,项目名称:oglplus,代码行数:11,代码来源:029_muddy_stones.cpp

示例15: Render

	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// set the matrix for camera orbiting the origin
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				3.5,
				Degrees(time * 35),
				Degrees(SineWave(time / 60.0) * 80)
			)
		);
		// set the model matrix
		model_matrix.Set(
			ModelMatrixf::RotationX(FullCircles(time * 0.25))
		);

		torus_instr.Draw(torus_indices);
	}
开发者ID:xdray,项目名称:oglplus,代码行数:20,代码来源:016_metallic_torus.cpp


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