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


C++ Light::InterpolateR方法代码示例

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


在下文中一共展示了Light::InterpolateR方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{

	glm::vec3 cross = glm::cross(glm::vec3(2.5, 2.5, 0),glm::vec3(0, 2.5, 0));
	try
	{
		GLfloat currentFrame;

		GLFWwindow *window = JPGLHelper::InitEverything(HEIGHT, WIDTH);
		glfwSetKeyCallback(window, keyCallback);
		
		if (glewInit() != GLEW_OK)
			throw std::runtime_error("glewInit() failed");

		ShaderCompiler shaderGround("ground.vert", "ground.frag");
		ShaderCompiler shaderTrain("train.vert", "train.frag");

		MatrixWrapper	modelPlane(shaderGround.GetProgramID(), "model"),
			modelIdentity(shaderTrain.GetProgramID(), "model"),
						projection(shaderGround.GetProgramID(), "projection");

		modelPlane.mat4	= glm::rotate(modelPlane.mat4, glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f));
		projection.mat4 = glm::perspective(glm::radians(45.0f), (GLfloat)WIDTH / (GLfloat)HEIGHT, 0.1f, 2500.0f);

		Camera camera(-180.0f, 180.0f, 0.0f, 360.0f, 5.0f, shaderGround.GetProgramID(), 25.0f);
		
		camera.UpdateTargetPosition(glm::vec3(0.0f, 0.0f, 0.0f));

		modelPlane.mat4 = glm::scale(modelPlane.mat4, glm::vec3(300.0f,300.0f, 1.0f));
		modelIdentity.mat4 = glm::mat4(1.0f);
		
		Plane ground(shaderGround.GetProgramID(),32);
		Train train(shaderTrain.GetProgramID());
		Light light;
	
		TextureWrapper groundTexture(GL_TEXTURE0, shaderGround.GetProgramID(), "ground.png", "Texture0");

		keyboardManager.RegisterKey(GLFW_KEY_ESCAPE, std::bind(glfwSetWindowShouldClose, window, GL_TRUE));
		keyboardManager.RegisterKey(GLFW_KEY_H, std::bind(&Camera::YawDown, std::ref(camera)));
		keyboardManager.RegisterKey(GLFW_KEY_J, std::bind(&Camera::PitchDown, std::ref(camera)));
		keyboardManager.RegisterKey(GLFW_KEY_K, std::bind(&Camera::PitchUp, std::ref(camera)));
		keyboardManager.RegisterKey(GLFW_KEY_L, std::bind(&Camera::YawUp, std::ref(camera)));
		keyboardManager.RegisterKey(GLFW_KEY_U, std::bind(&Camera::DistanceUp, std::ref(camera)));
		keyboardManager.RegisterKey(GLFW_KEY_I, std::bind(&Camera::DistanceDown, std::ref(camera)));

		keyboardManager.RegisterKey(GLFW_KEY_A, std::bind(&Train::Go, std::ref(train)));
		keyboardManager.RegisterKey(GLFW_KEY_Z, std::bind(&Train::Back, std::ref(train)));


		keyboardManager.RegisterKey(GLFW_KEY_S, std::bind(&Light::AmbientUp, std::ref(light)));
		keyboardManager.RegisterKey(GLFW_KEY_X, std::bind(&Light::AmbientDown, std::ref(light)));
		keyboardManager.RegisterKey(GLFW_KEY_D, std::bind(&Light::DiffuseUp, std::ref(light)));
		keyboardManager.RegisterKey(GLFW_KEY_C, std::bind(&Light::DiffuseDown, std::ref(light)));

		glEnable(GL_MULTISAMPLE);
		glEnable(GL_DEPTH_TEST);
		glEnable(GL_CULL_FACE);

		while (!glfwWindowShouldClose(window))
		{
			currentFrame = glfwGetTime();
			JPGLHelper::deltaTime = currentFrame - JPGLHelper::lastTime;
			JPGLHelper::lastTime = currentFrame;

			glfwPollEvents();
			keyboardManager.ProcessKeys();
			
			camera.UpdateTargetPosition(train.GetLocation());
			train.DoPhysics();

			glClearColor(light.InterpolateR(), light.InterpolateG(), light.InterpolateB(), 1.0f);
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

			/*
			
				rysowanie p³aszczyzny

			*/

			groundTexture.SendToGPU();

			shaderGround.Execute();

			light.UpdateLight(shaderGround.GetProgramID(), camera.cameraPosition);

			camera.UpdateShader(shaderGround.GetProgramID());
			camera.SendUpdatedMatrix();
			
			projection.SetShader(shaderGround.GetProgramID());
			projection.SendToGPU();

			ground.Draw(modelPlane);


			/*
			
				rysowanie poci¹gu
			
			*/

//.........这里部分代码省略.........
开发者ID:jpalczewski,项目名称:Animacja,代码行数:101,代码来源:main.cpp


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