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


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

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


在下文中一共展示了Context::DrawArrays方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
	}
开发者ID:Extrunder,项目名称:oglplus,代码行数:57,代码来源:023_reflected_cube.cpp

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

示例3: Render

	void Render(double time)
	{
		std::size_t metaball_count = ball_paths.size(), k = 0;
		std::vector<GLfloat> metaballs(metaball_count*4);
		for(std::size_t ball=0; ball != metaball_count; ++ball)
		{
			Vec4f pos = ball_paths[ball].Position(time / 10.0);

			for(std::size_t coord=0; coord != 4; ++coord)
				metaballs[k++] = pos.At(coord);
		}

		Texture::Image1D(
			Texture::Target::_1D,
			0,
			PixelDataInternalFormat::RGBA32F,
			metaball_count,
			0,
			PixelDataFormat::RGBA,
			PixelDataType::Float,
			metaballs.data()
		);
		gl.Clear().DepthBuffer();
		gl.DrawArrays(PrimitiveType::TriangleStrip, 0, 4);
	}
开发者ID:xdray,项目名称:oglplus,代码行数:25,代码来源:009_metaballs.cpp

示例4: Render

	void Render(const PangoCairoLayout& layout)
	{
		_bitmap.Set(GLint(layout.Use()));
		_log_coords.Set(layout._log_coords);
		_tex_coords.Set(layout._tex_coords);
		_gl.DrawArrays(PrimitiveType::Points, 0, 1);
	}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:7,代码来源:renderer.hpp

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

示例6: operator

	void operator()(const Particles& particles)
	{
		gl.Bind(vao);
		gl.Use(prog);
		xfb.BeginPoints();
		gl.DrawArrays(PrimitiveType::Points, 0, particles.Count());
		xfb.End();
	}
开发者ID:Extrunder,项目名称:oglplus,代码行数:8,代码来源:029_gpu_sort_tfb.cpp

示例7: Render

	void Render(double /*time*/)
	{
		gl.Clear().ColorBuffer();
		// draw the lines between control points
		color = Vec3f(0.9f, 0.9f, 0.2f);
		control.Bind();
		gl.DrawArrays(PrimitiveType::LineStrip, 0, ctrl_n);
		// draw the curve
		color = Vec3f(0.1f, 0.1f, 0.1f);
		curve.Bind();
		gl.DrawArrays(PrimitiveType::LineStrip, 0, curve_n);
		// draw the control points
		color = Vec3f(0.9f, 0.0f, 0.0f);
		control.Bind();
		gl.PointSize(8.0);
		gl.DrawArrays(PrimitiveType::Points, 0, ctrl_n);
		gl.PointSize(1.0);
	}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:18,代码来源:007_cubic_bezier.cpp

示例8: Render

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

		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				3.5 + SineWave(time / 6.0)*0.5,
				FullCircles(time * 0.2),
				Degrees(SineWave(time / 20.0) * 80)
			)
		);
		gl.DrawArrays(PrimitiveType::Points, 0, 1);
	}
开发者ID:xdray,项目名称:oglplus,代码行数:14,代码来源:021_cloud.cpp

示例9: Render

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

		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				GLfloat(30.0 - SineWave(time / 17.0)*25.0),
				Degrees(time * 47),
				Degrees(SineWave(time / 31.0) * 90)
			)
		);

		gl.DrawArrays(PrimitiveType::Patches, 0, 16);
	}
开发者ID:xubingyue,项目名称:oglplus,代码行数:15,代码来源:019_bpatch_tess.cpp

示例10: BeginTransform

unsigned SpectraDefaultGPUMatrixTransf::BeginTransform(
	const float* input,
	std::size_t inbufsize,
	float* /*output*/,
	std::size_t /*outbufsize*/
)
{
	using namespace oglplus;

	assert(inbufsize >= in_size);

	if(current_transform >= max_transforms)
		current_transform = 0;

	input_buf.Bind(Buffer::Target::Texture);
	Buffer::SubData(
		Buffer::Target::Texture,
		current_transform*in_size,
		in_size,
		input
	);

	prog_input_offs.Set(current_transform*in_size);

	xfbs[current_transform].Bind();

	Query::Activator qrya(
		queries[current_transform],
		Query::Target::TransformFeedbackPrimitivesWritten
	);
	TransformFeedback::Activator xfba(
		TransformFeedbackPrimitiveType::Points
	);

	Context gl;
	gl.DrawArrays(PrimitiveType::Points, 0, out_size);

	xfba.Finish();
	qrya.Finish();

	TransformFeedback::BindDefault();

	return current_transform++;
}
开发者ID:BrainlessLabsInc,项目名称:oglplus,代码行数:44,代码来源:calculator_gpu.cpp

示例11: Render

    void Render(double time)
    {
        gl.Clear().ColorBuffer().DepthBuffer();
        //
        // set the matrix for camera orbiting the origin
        camera_matrix.Set(
            CamMatrixf::LookingAt(
                cam_path.Position(time / 9.0),
                tgt_path.Position(time / 7.0)
            )
        );

        // draw the points
        gl.DrawArrays(PrimitiveType::Points, 0, node_count * 3);
        // draw the edges
        gl.DrawElements(
            PrimitiveType::Lines,
            edge_count,
            DataType::UnsignedInt
        );
    }
开发者ID:xdray,项目名称:oglplus,代码行数:21,代码来源:015_graph.cpp

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

示例13: Render

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

		auto cameraMatrix = CamMatrixf::Orbiting(
			Vec3f(0.0f, 3.0f, 0.0f),
			8.0f,
			FullCircles(time / 12.0),
			Degrees(SineWave(time / 20.0) * 80)
		);

		plane.Bind();
		plane_prog.Use();
		Uniform<Mat4f>(plane_prog, "CameraMatrix").Set(cameraMatrix);

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

		gl.Enable(Capability::Blend);

		volume.Bind();
		volume_prog.Use();
		Uniform<Mat4f>(volume_prog, "CameraMatrix").Set(cameraMatrix);
		Uniform<Vec3f>(volume_prog, "ViewX").Set(
			cameraMatrix.Row(0).xyz()
		);
		Uniform<Vec3f>(volume_prog, "ViewY").Set(
			cameraMatrix.Row(1).xyz()
		);
		Uniform<Vec3f>(volume_prog, "ViewZ").Set(
			cameraMatrix.Row(2).xyz()
		);
		gl.DrawArraysInstanced(
			PrimitiveType::Points,
			0, 1,
			samples
		);

		gl.Disable(Capability::Blend);
	}
开发者ID:Extrunder,项目名称:oglplus,代码行数:39,代码来源:022_volumetric_light.cpp

示例14: Render

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

		gl.DrawArrays(PrimitiveType::TriangleStrip, 0, 4);
	}
开发者ID:detunized,项目名称:oglplus,代码行数:6,代码来源:002_shader_lit.cpp

示例15: Render

	void Render(double /*time*/)
	{
		gl.Clear().ColorBuffer();
		// draw the curve
		gl.DrawArrays(PrimitiveType::LineStrip, 0, curve_n);
	}
开发者ID:detunized,项目名称:oglplus,代码行数:6,代码来源:011_writing.cpp


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