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

		auto camera = CameraMat(time);

		mesh_proc.prog.model_matrix = ModelMat(time);
		mesh_proc.prog.camera_matrix = camera;
		dist_proc.prog.camera_matrix = camera;
		draw_proc.prog.camera_matrix = camera;

		mesh_proc();
		dist_proc(particles);
		sort_proc(particles);
		draw_proc(particles);
	}
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// set the matrix for camera orbiting the origin
		Uniform<Mat4f>(prog, "CameraMatrix").Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				5.0,
				FullCircles(time / 17.0),
				Degrees(SineWave(time / 19.0) * 90)
			)
		);

		torus_instr.Draw(torus_indices);
	}
Exemple #3
0
	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 * 135),
				Degrees(SineWave(time / 20.0) * 90)
			)
		);

		sphere_instr.Draw(sphere_indices);
	}
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// set the matrix for camera orbiting the origin
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				4.5f,
				FullCircles(time / 10.0),
				Degrees(45.0 + SineWave(time / 7.0)*30.0)
			)
		);
		model_matrix.Set(ModelMatrixf::RotationX(FullCircles(time / 12.0)));

		torus_instr.Draw(torus_indices);
	}
    void Render(double time) {
        gl.Clear().ColorBuffer().DepthBuffer();
        //
        auto lightAzimuth = FullCircles(time * -0.5);
        light_pos.Set(
          Vec3f(-Cos(lightAzimuth), 1.0f, -Sin(lightAzimuth)) * 2.0f);
        //
        camera_matrix.Set(CamMatrixf::Orbiting(
          Vec3f(), 3.0f, Degrees(-45), Degrees(SineWave(time / 30.0) * 70)));

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

        gl.CullFace(Face::Back);
        cube_instr.Draw(cube_indices);
    }
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// make the light position vector
		auto light = Vec3f(2.0f, 2.0f, 2.0f);
		// make the matrix for camera orbiting the origin
		auto camera = CamMatrixf::Orbiting(
			Vec3f(),
			6.0,
			Degrees(time * 15),
			Degrees(SineWave(time / 6.0) * 45)
		);
		// render the shapes
		sphere.Render(light, camera, Mat4f());
		cubeX.Render(
			light,
			camera,
			ModelMatrixf::Translation(2.0f, 0.0f, 0.0f) *
			ModelMatrixf::RotationX(Degrees(time * 45))
		);
		cubeY.Render(
			light,
			camera,
			ModelMatrixf::Translation(0.0f, 2.0f, 0.0f) *
			ModelMatrixf::RotationY(Degrees(time * 90))
		);
		cubeZ.Render(
			light,
			camera,
			ModelMatrixf::Translation(0.0f, 0.0f, 2.0f) *
			ModelMatrixf::RotationZ(Degrees(time * 135))
		);
		torus.Render(
			light,
			camera,
			ModelMatrixf::Translation(-1.0f, -1.0f, -1.0f) *
			ModelMatrixf::RotationA(
				Vec3f(1.0f, 1.0f, 1.0f),
				Degrees(time * 45)
			) *
			ModelMatrixf::RotationY(Degrees(45)) *
			ModelMatrixf::RotationX(Degrees(45))
		);
	}
	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);
	}
Exemple #8
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);
	}
	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);
	}
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// set the matrix for camera orbiting the origin
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				18.5,
				Degrees(time * 135),
				Degrees(SineWave(time / 20.0) * 30)
			)
		);

		// draw 36 instances of the cube
		// the vertex shader will take care of their placement
		cube_instr.Draw(cube_indices, 36);
	}
Exemple #11
0
    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);
    }
	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);
	}
Exemple #13
0
	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);
	}
    void Render(double time) {
        gl.Clear().ColorBuffer().DepthBuffer();

        auto camera = CamMatrixf::Orbiting(
          Vec3f(),
          2.9f,
          FullCircles(time / 17.0),
          Degrees(45 + SineWave(time / 20.0) * 40));

        camera_matrix.Set(camera);
        camera_position.Set(camera.Position());

        auto langle = FullCircles(time / 31.0);
        light_position.Set(
          GLfloat(Cos(langle) * 20.0f),
          GLfloat((1.2 + Sin(langle)) * 15.0f),
          GLfloat(Sin(langle) * 20.0f));

        shape.Draw();
    }
Exemple #15
0
    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
        );
    }
	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);
	}
	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);
	}
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		Vec3f lightPos(-1.0f, 2.0f, 2.0f);
		lightPos *= (1.0f - SineWave(time/5.0f)*0.4f);
		light_pos.Set(lightPos);

		tex_projection_matrix.Set(
			CamMatrixf::PerspectiveX(Degrees(15), 1.0, 1, 20) *
			CamMatrixf::LookingAt(lightPos, Vec3f())
		);

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

		cube.Bind();
		gl.CullFace(Face::Front);
		cube_instr.Draw(cube_indices);
	}
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		camera_matrix.Set(
			CamMatrixf::LookingAt(
				Vec3f(2.5, 3.5, 2.5),
				Vec3f()
			)
		);

		model_matrix.Set(
			ModelMatrixf::Translation(
				0.0f,
				sqrt(1.0f+SineWave(time / 2.0)),
				0.0f
			) *
			ModelMatrixf::RotationY(Degrees(time * 180))
		);

		sphere_instr.Draw(sphere_indices);
	}
	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();
	}
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		CamMatrixf camera = CamMatrixf::Orbiting(
			Vec3f(),
			4.5 - SineWave(time / 16.0) * 1.5,
			FullCircles(time / 12.0),
			Degrees(SineWave(time / 30.0) * 90)
		);
		// set the matrix for camera orbiting the origin
		camera_matrix_3.Set(projection * camera);
		camera_position_3.Set(camera.Position());

		// set the model matrix
		model_matrix.Set(
			ModelMatrixf::RotationX(FullCircles(time / 10.0))
		);

		shape.Bind();
		shape_instr.Draw(shape_indices);
	}
Exemple #22
0
	void Render(double time)
	{
		ripples.Update();

		DefaultFramebuffer::Bind(Framebuffer::Target::Draw);
		gl.DrawBuffer(ColorBuffer::BackLeft);
		gl.Viewport(width, height);
		gl.Clear().ColorBuffer().DepthBuffer();

		auto camera = CamMatrixf::Orbiting(
			Vec3f(),
			6.0 + SineWave(time / 31.0),
			FullCircles(time / 17.0),
			Degrees(50 + SineWave(time / 21.0) * 35)
		);

		water_prog.Use();
		water_prog.camera_matrix.Set(camera);
		water_prog.camera_position.Set(camera.Position());

		water.Draw();
	}
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		auto camera = CamMatrixf::Orbiting(
			Vec3f(),
			14.0 - SineWave(time / 13)*8.0,
			Degrees(time * 33),
			Degrees(SineWave(time / 21.0) * 31)
		);
		camera_matrix = camera;

		const Vec3f offsets[6] = {
			Vec3f( 2, 0, 0),
			Vec3f(-2, 0, 0),
			Vec3f( 0, 2, 0),
			Vec3f( 0,-2, 0),
			Vec3f( 0, 0, 2),
			Vec3f( 0, 0,-2)
		};

		for(int i=0; i!=6; ++i)
		{
			auto model =
				ModelMatrixf::RotationX(Degrees(time * 11))*
				ModelMatrixf::Translation(offsets[i])*
				ModelMatrixf::RotationZ(Degrees(time * (37+9*i)));

			model_matrix = model;
			offset = offsets[i];
			view_position = (
				Inverse(model)*
				Vec4f(camera.Position(), 1)
			).xyz();

			shape_instr.Draw(shape_indices);
		}
	}
Exemple #24
0
    void Render(double time)
    {
        gl.Clear().ColorBuffer().DepthBuffer();

        auto lightPos = light_path.Position(time * 0.05);
        auto cameraMatrix = CamMatrixf::Orbiting(
                                Vec3f(),
                                4.5f,
                                Degrees(0),
                                Degrees(SineWave(time / 20.0) * 80)
                            );

        light.Bind();
        light_prog.Use();

        Uniform<Vec3f>(light_prog, "LightPos").Set(lightPos);
        Uniform<Mat4f>(light_prog, "CameraMatrix").Set(cameraMatrix);

        sphere_instr.Draw(sphere_indices);

        clouds.Bind();
        cloud_prog.Use();

        Uniform<Vec3f>(cloud_prog, "LightPos").Set(lightPos);
        Uniform<Mat4f>(cloud_prog, "CameraMatrix").Set(cameraMatrix);
        Uniform<Vec4f>(cloud_prog, "ViewX").Set(cameraMatrix.Row(0));
        Uniform<Vec4f>(cloud_prog, "ViewY").Set(cameraMatrix.Row(1));
        Uniform<Vec4f>(cloud_prog, "ViewZ").Set(cameraMatrix.Row(2));
        for(std::size_t i=0, n=positions.size(); i!=n; ++i)
        {
            cloud_tex[i].Bind(Texture::Target::_3D);
            gl.DrawArraysInstanced(
                PrimitiveType::Points,
                i, 1,
                samples
            );
        }
    }
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// set the matrix for camera orbiting the origin
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				7.5 - SineWave(time / 6.0) * 6.0,
				FullCircles(time * 0.03),
				Degrees(SineWave(time / 30.0) * 90)
			)
		);

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

		cube.Bind();
		gl.CullFace(Face::Back);
		cube_instr.Draw(cube_indices);
	}
Exemple #26
0
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		auto camera = CamMatrixf::Orbiting(
			Vec3f(),
			15.0 - SineWave(time / 13)*8.0,
			Degrees(time * 33),
			Degrees(SineWave(time / 21.0) * 31)
		);
		camera_matrix = camera;

		const Vec3f offsets[4] = {
			Vec3f( 2, 0, 0),
			Vec3f(-2, 0, 0),
			Vec3f( 0, 0, 2),
			Vec3f( 0, 0,-2)
		};

		for(int i=0; i!=4; ++i)
		{
			auto model =
				ModelMatrixf::RotationX(Degrees(time * 11))*
				ModelMatrixf::Translation(offsets[i])*
				ModelMatrixf::RotationZ(Degrees(time * (37+3*i)));

			GLint level = GLint(17.0 / (Length((
				Inverse(model)*
				Vec4f(camera.Position(), 1)
			).xyz())+0.1));

			model_matrix = model;
			tess_level = level;

			shape_instr.Draw(shape_indices);
		}
	}
    void Render(ExampleClock& clock) {
        gl.Clear().ColorBuffer().DepthBuffer();

        double time = clock.Now().Seconds();

        auto langle = FullCircles(time / 23.0);
        light_position.Set(
          GLfloat(Cos(langle) * 20.0),
          GLfloat((1.2 + Sin(langle)) * 15.0),
          GLfloat(Sin(langle) * 20.0));

        double x = SineWave(time / 13.0);
        if(x + 0.93 < 0.0)
            clock.Pace(0.2);
        else
            clock.Pace(1.0);

        auto camera = CamMatrixf::Orbiting(
          Vec3f(),
          GLfloat(9.5 + x * 5.1),
          FullCircles(time / 17.0),
          Degrees(SineWave(time / 20.0) * 89));

        camera_matrix.Set(camera);
        camera_position.Set(camera.Position());

        model_matrix.Set(
          ModelMatrixf::TranslationX(+2.0f) *
          ModelMatrixf::RotationX(FullCircles(time / 13.0)));
        shape.Draw();

        model_matrix.Set(
          ModelMatrixf::TranslationX(-2.0f) *
          ModelMatrixf::RotationZ(FullCircles(time / 11.0)));
        shape.Draw();
    }
	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
		);
	}
Exemple #29
0
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// make the light position vector
		auto light = Vec3f(8.0f, 8.0f, 8.0f);
		// make the matrix for camera orbiting the origin
		auto camera = CamMatrixf::Orbiting(
			Vec3f(),
			21.0,
			Degrees(time * 15),
			Degrees(SineWave(time*0.15) * 45)
		);
		auto nucl = ModelMatrixf::RotationA(
			Vec3f(1.0f, 1.0f, 1.0f),
			FullCircles(time)
		);

		proton.SetLightAndCamera(light, camera);
		proton.Render(nucl * ModelMatrixf::Translation(+1.4f,0.0f,0.0f));
		proton.Render(nucl * ModelMatrixf::Translation(-1.4f,0.0f,0.0f));

		neutron.SetLightAndCamera(light, camera);
		neutron.Render(nucl * ModelMatrixf::Translation(0.0f,0.0f,+1.0f));
		neutron.Render(nucl * ModelMatrixf::Translation(0.0f,0.0f,-1.0f));

		electron.SetLightAndCamera(light, camera);
		electron.Render(
			ModelMatrixf::RotationY(FullCircles(time * 0.7)) *
			ModelMatrixf::Translation(10.0f, 0.0f, 0.0f)
		);
		electron.Render(
			ModelMatrixf::RotationX(FullCircles(time * 0.7)) *
			ModelMatrixf::Translation(0.0f, 0.0f, 10.0f)
		);
	}
Exemple #30
0
	void RenderShadowMap(
		const Vec3f& light_position,
		const Mat4f& torus_matrix,
		const Mat4f& light_proj_matrix
	)
	{
		frame_shadow_fbo.Bind(Framebuffer::Target::Draw);

		gl.Viewport(shadow_tex_side, shadow_tex_side);
		gl.Clear().DepthBuffer();
		gl.CullFace(Face::Back);

		transf_prog.camera_matrix.Set(light_proj_matrix);
		transf_prog.camera_position.Set(light_position);

		// Render the torus' frame
		transf_prog.model_matrix.Set(torus_matrix);

		shadow_pp.Bind();

		gl.Enable(Capability::PolygonOffsetFill);
		torus.Draw();
		gl.Disable(Capability::PolygonOffsetFill);
	}