コード例 #1
0
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();

		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				4.0,
				Degrees(time * 25),
				Degrees(SineWave(time / 30.0) * 90)
			)
		);

		model_matrix.Set(
			ModelMatrixf::RotationA(
				Vec3f(1.0f, 1.0f, 1.0f),
				FullCircles(time * 0.5)
			)
		);

		shape.Draw();

		thread_ready.Signal();
		parent_ready.Wait();
	}
コード例 #2
0
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();

		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				3.0,
				Degrees(time * 35),
				Degrees(SineWave(time / 20.0) * 60)
			)
		);

		model_matrix.Set(ModelMatrixf::RotationX(FullCircles(time * 0.25)));

		assert(thread_ready);
		thread_ready->Wait();

		cube.Draw();

		parent_ready.Signal();
	}
コード例 #3
0
	void Render(double time)
	{
		gl.Clear().ColorBuffer().StencilBuffer();

		int border = 20;
		std::stringstream text;

		// shape colors
		GLfloat shape_color_gen_coeffs[9] = {
			 0.0f, 0.0f, 0.2f,
			 0.2f, 0.0f, 0.2f,
			 0.0f, 0.0f, 0.2f
		};
		npr.ColorGen(
			PathNVColor::Primary,
			PathNVGenMode::ObjectBoundingBox,
			PathNVColorFormat::RGB,
			shape_color_gen_coeffs
		);

		// Shape
		dsa.ModelviewMatrix()
			.LoadIdentity()
			.Translate(64, 64, 0)
			.Translate(192, 192, 0)
			.Rotate(RightAngles(time), Vec3f::Unit(2))
			.Translate(-192, -192, 0);
		shape.StencilFill(PathNVFillMode::CountUp, 0xFF);
		shape.CoverFill(PathNVFillCoverMode::BoundingBox);

		// text colors
		GLfloat text_color_gen_coeffs[9] = {
			-0.3f, 0.0f, 0.3f,
			 0.0f, 0.2f, 0.6f,
			 0.3f, 0.0f, 0.0f
		};
		npr.ColorGen(
			PathNVColor::Primary,
			PathNVGenMode::ObjectBoundingBox,
			PathNVColorFormat::RGB,
			text_color_gen_coeffs
		);

		// Time
		dsa.ModelviewMatrix()
			.LoadIdentity()
			.Translate(border, border, 0);
		text	<< "Time: "
			<< std::setw(7)
			<< std::setprecision(2)
			<< std::fixed
			<< time << "[s]";
		RenderText(text.str());
		text.str(std::string());

		// Frame no
		dsa.ModelviewMatrix()
			.LoadIdentity()
			.Translate(tex_side-border, border, 0)
			.Rotate(RightAngle(), Vec3f::Unit(2));
		text	<< "Frame: "
			<< std::setw(7)
			<< std::fixed
			<< frame_no;
		RenderText(text.str());
		text.str(std::string());

		// FPS
		dsa.ModelviewMatrix()
			.LoadIdentity()
			.Translate(tex_side-border, tex_side-border, 0)
			.Rotate(RightAngles(2), Vec3f::Unit(2));
		text	<< "FPS: ";
		if(time < 1) text << "<N/A>";
		else text << std::setw(7) << std::fixed << frame_no / time;
		RenderText(text.str());
		text.str(std::string());

		// title
		dsa.ModelviewMatrix()
			.LoadIdentity()
			.Translate(border, tex_side-border, 0)
			.Rotate(RightAngles(3), Vec3f::Unit(2));
		RenderText("OpenGL");

		// sync
		thread_ready.Signal();
		parent_ready.Wait();

		++frame_no;
	}
コード例 #4
0
	void Cancel(void)
	{
		parent_ready.Cancel();
		thread_ready.Cancel();
	}