Example #1
0
	void Render(double time)
	{
		static const Mat4f reflection(
			Vec4f( 1.0, 0.0, 0.0, 0.0),
			Vec4f( 0.0,-1.0, 0.0, 0.0),
			Vec4f( 0.0, 0.0, 1.0, 0.0),
			Vec4f( 0.0, 0.0, 0.0, 1.0)
		);

		auto camera = CamMatrixf::Orbiting(
			Vec3f(),
			GLfloat(7.0 + SineWave(time / 12.0)*2.5),
			FullCircles(time / 10.0),
			Degrees(45.0 - SineWave(time / 7.0)*35.0)
		);

		shape_prog.Use();
		shape.Bind();

		gl.Enable(Capability::CullFace);
		gl.FrontFace(make_shape.FaceWinding());

		// render into the off-screen framebuffer
		fbo.Bind(Framebuffer::Target::Draw);
		gl.Viewport(
			(width - refl_tex_side) / 2,
			(height - refl_tex_side) / 2,
			refl_tex_side, refl_tex_side
		);
		gl.Clear().ColorBuffer().DepthBuffer();

		shape_camera_matrix.Set(
			camera *
			ModelMatrixf::Translation(0.0f, -1.0f, 0.0f) *
			reflection
		);

		gl.CullFace(Face::Front);
		shape_instr.Draw(shape_indices);

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

		shape_camera_matrix.Set(camera);

		gl.CullFace(Face::Back);
		shape_instr.Draw(shape_indices);

		gl.Disable(Capability::CullFace);

		// Render the plane
		plane_prog.Use();
		plane.Bind();

		plane_camera_matrix.Set(camera);
		plane_camera_position.Set(camera.Position());

		plane_instr.Draw(plane_indices);
	}
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				3.0f,
				Degrees(time * 50),
				Degrees(SineWave(time / 16.0) * 80)
			)
		);
		// the model matrix
		model_matrix.Set(
			ModelMatrixf::RotationY(Degrees(time * 25))
		);
		// draw 36 instances of the cube
		// first the back faces
		gl.CullFace(Face::Front);
		front_facing.Set(0);
		cube_instr.Draw(cube_indices, inst_count);
		// then the front faces
		gl.CullFace(Face::Back);
		front_facing.Set(1);
		cube_instr.Draw(cube_indices, inst_count);
	}
Example #3
0
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// set the matrix for camera orbiting the origin
		camera_matrix.Set(
			CamMatrixf::Orbiting(
				Vec3f(),
				4.5,
				Degrees(time * 35),
				Degrees(SineWave(time / 20.0) * 60)
			)
		);
		// set the model matrix
		model_matrix.Set(
			ModelMatrixf::RotationX(FullCircles(time * 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);
	}
Example #4
0
 void Reshape(GLuint width, GLuint height) {
     gl.Viewport(width, height);
     auto projection =
       CamMatrixf::PerspectiveX(Degrees(70), float(width) / height, 1, 200);
     sky_box_projection_matrix.Set(projection);
     shape_projection_matrix.Set(projection);
 }
 void Reshape(GLuint width, GLuint height) {
     gl.Viewport(width, height);
     Mat4f projection =
       CamMatrixf::PerspectiveX(Degrees(70), float(width) / height, 1, 40);
     shape_projection_matrix.Set(projection);
     plane_projection_matrix.Set(projection);
     halo_projection_matrix.Set(projection);
 }
Example #6
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);
	}
Example #7
0
	void Reshape(GLuint width, GLuint height)
	{
		gl.Viewport(width, height);
		projection_matrix.Set(
			CamMatrixf::PerspectiveX(
				Degrees(70),
				width, height,
				1, 100
			)
		);
	}
	void Reshape(GLuint width, GLuint height)
	{
		gl.Viewport(width, height);
		prog.Use();
		projection_matrix.Set(
			CamMatrixf::PerspectiveX(
				Degrees(70),
				double(width)/height,
				1, 20
			)
		);
	}
Example #9
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);
	}
Example #10
0
    void Render(double time) {
        const double day_duration = 67.0;
        auto sun =
          Vec3f(0.000, 1.000, 0.000) * 1e10 * SineWave(time / day_duration) +
          Vec3f(0.000, 0.000, -1.000) * 1e10 * CosineWave(time / day_duration);

        auto camera = CamMatrixf::Orbiting(
          Vec3f(),
          5.0,
          FullCircles(-0.10 - time / 27.0),
          Degrees(-20 - SineWave(time / 17.0) * 30));

        auto model = ModelMatrixf::RotationA(
          Vec3f(1.0, 1.0, 1.0), FullCircles(time / 13.0));

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

        sky_box.Use();
        sky_box_prog.Use();
        sky_box_camera_matrix.Set(camera);
        sky_box_sun_position.Set(sun);
        sky_box.Draw();

        shape.Use();
        shape_prog.Use();
        shape_model_matrix.Set(model);
        shape_camera_matrix.Set(camera);
        shape_camera_position.Set(camera.Position());
        shape_sun_position.Set(sun);
        shape.Draw();
    }
	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);
	}
Example #12
0
	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);
	}