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


C++ ObjectPool::Add方法代码示例

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


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

示例1: main

int main(void)
{
	srand(time(NULL));
	int width, height;
	double startTime, waitTime, frameTime = 1000.0 / 80.0;	

	setupWindow();	
	Human::InitBuffers();
	bool done = false;
	#ifdef PREVIEW_MODEL
	Human * my_human = new Human(MVP_LOC, rand() % 90 + 45, 0.0f, (HumanColor)(rand() % 4));
	#else
	Human * my_human = new Human(MVP_LOC, rand() % 90 + 45, (rand() % 100 + 20.0f) / 1000.0f, (HumanColor)(rand() % 4));
	#endif
	my_human->SetActive(true);
	humans.Add(my_human); 

	// Projection matrix : 80° Field of View, 4:3 ratio, display range : 0.1 unit <-> 100 units
	mat4 projection = glm::perspective(80.0f, 4.0f / 3.0f, 0.1f, 1000.0f);
	mat4 view;

	int counter = 0;
	int next_human = 100;
	while (!glfwWindowShouldClose(window))
	{		
		startTime = glfwGetTime();			

		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );				
		glfwGetWindowSize(window, &width, &height);	
		glViewport(0, 0, width, height);
			
		view = setCamera();

		for(int i = 0; i < maxHumans; i++)
			if (humans[i] != NULL)
				humans[i]->Draw(projection, view, cameraType != first_person && cameraType != mouse_control, cameraType == perspective_view);

		#ifndef PREVIEW_MODEL
		if (++counter == next_human)
		{		
			next_human = rand() % 100 + 60;
			counter = 0;
			humans.Add(new Human(MVP_LOC, rand() % 90 + 45,
								(rand() % 100 + 20.0f) / 1000.0f, 
								(HumanColor)(rand() % 4))); 
		}
		#endif

		glfwSwapBuffers(window);
		glfwPollEvents();

		waitTime = frameTime - (glfwGetTime() - startTime) * 1000.0;		
		if (waitTime > 0)
			Sleep(waitTime);		
	}

	Human::DestroyBuffers();
	glfwDestroyWindow(window);
	glfwTerminate();
	exit(EXIT_SUCCESS);
}
开发者ID:scuhurricane,项目名称:Sample-Projects,代码行数:61,代码来源:main.cpp


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