예제 #1
0
	void Reshape(GLuint vp_width, GLuint vp_height)
	{
		width = vp_width;
		height = vp_height;

		float aspect = float(width)/height;

		auto projection =
			CamMatrixf::PerspectiveX(Degrees(60), aspect, 1, 20);

		plane_projection_matrix.Set(projection);
		shape_projection_matrix.Set(projection);

		Bind(depth_tex, Texture::Target::Rectangle).Image2D(
			0,
			PixelDataInternalFormat::DepthComponent,
			width/tex_size_div, height/tex_size_div,
			0,
			PixelDataFormat::DepthComponent,
			PixelDataType::Float,
			nullptr
		);
		Bind(reflect_tex, Texture::Target::Rectangle).Image2D(
			0,
			PixelDataInternalFormat::RGB,
			width/tex_size_div, height/tex_size_div,
			0,
			PixelDataFormat::RGB,
			PixelDataType::UnsignedByte,
			nullptr
		);
	}
예제 #2
0
	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(time * 0.33));

		camera_matrix.Set(camera);
		model_matrix.Set(model);
		transf_time.Set(time);

		face_pp.Bind();
		gl.PolygonMode(PolygonMode::Fill);
		torus_instr.Draw(torus_indices);

		frame_pp.Bind();
		gl.PolygonMode(PolygonMode::Line);
		torus_instr.Draw(torus_indices);
	}
예제 #3
0
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();

		auto camera = CamMatrixf::Orbiting(
			Vec3f(),
			6.0,
			FullCircles(time / 10.0),
			Degrees(45.0 + SineWave(time / 7.0)*30.0)
		);
		auto model = ModelMatrixf::RotationX(FullCircles(time / 12.0));

		plane_camera_matrix.Set(camera);
		torus_camera_matrix.Set(camera);
		torus_model_matrix.Set(model);

		BSP(camera, 0);
	}
예제 #4
0
	void RenderPlane(std::size_t p)
	{
		gl.Enable(Capability::Blend);
		plane_prog.Use();
		plane_normal.Set(make_plane[p].Normal());
		plane[p].Bind();
		plane_instr.Draw(plane_indices);
		gl.Disable(Capability::Blend);
	}
예제 #5
0
	void Reshape(GLuint width, GLuint height)
	{
		gl.Viewport(width, height);
		projection_matrix.Set(
			CamMatrixf::PerspectiveX(
				Degrees(60),
				double(width)/height,
				1, 20
			)
		);
	}
예제 #6
0
	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);
	}
예제 #7
0
	void Reshape(GLuint vp_width, GLuint vp_height)
	{
		width = vp_width;
		height = vp_height;

		viewport_width.Set(width);
		viewport_height.Set(height);

		projection_matrix.Set(
			CamMatrixf::PerspectiveX(
				Degrees(65),
				double(width)/height,
				4.0, 50.0
			)
		);

		Bind(color_tex, Texture::Target::Rectangle).Image2D(
			0,
			PixelDataInternalFormat::RGB,
			width, height,
			0,
			PixelDataFormat::RGB,
			PixelDataType::UnsignedByte,
			nullptr
		);

		Bind(depth_tex, Texture::Target::Rectangle).Image2D(
			0,
			PixelDataInternalFormat::DepthComponent,
			width, height,
			0,
			PixelDataFormat::DepthComponent,
			PixelDataType::Float,
			nullptr
		);
		gl.Viewport(width, height);
	}
예제 #8
0
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(0.0f, 0.5f, 0.0f),
				2.8,
				FullCircles(time / 90.0),
				Degrees(85)
			)
		);
		vc_int.Set(SineWave(time / 5.0 - 0.25));
		gc_int.Set(SineWave(time / 6.0));
		fc_int.Set(SineWave(time / 7.0 + 0.25));

		plane_instr.Draw(plane_indices);

		const GLuint tmp[3] = {0u, 0u, 0u};
		Buffer::SubData(
			Buffer::Target::AtomicCounter,
			0, 3, tmp
		);
	}
예제 #9
0
	void Render(double time)
	{
		fbo.Bind(Framebuffer::Target::Draw);

		gl.Clear().ColorBuffer().DepthBuffer();

		main_prog.Use();
		cube.Bind();

		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				20.5,
				FullCircles(time / 20.0),
				Degrees(SineWave(time / 25.0) * 30)
			)
		);

		auto i = cube_matrices.begin(), e = cube_matrices.end();
		while(i != e)
		{
			model_matrix.Set(*i);
			ambient_color.Set(0.7f, 0.6f, 0.2f);
			diffuse_color.Set(1.0f, 0.8f, 0.3f);
			face_instr.Draw(face_indices);

			ambient_color.Set(0.1f, 0.1f, 0.1f);
			diffuse_color.Set(0.3f, 0.3f, 0.3f);
			edge_instr.Draw(edge_indices);
			++i;
		}

		dfb.Bind(Framebuffer::Target::Draw);

		gl.Clear().ColorBuffer().DepthBuffer();

		dof_prog.Use();
		screen.Bind();

		focus_depth.Set(0.6 + SineWave(time / 9.0)*0.3);

		gl.Enable(Capability::Blend);
		gl.DrawArrays(PrimitiveType::TriangleStrip, 0, 4);
		gl.Disable(Capability::Blend);
	}