當前位置: 首頁>>代碼示例>>C++>>正文


C++ ObjectManager::render方法代碼示例

本文整理匯總了C++中ObjectManager::render方法的典型用法代碼示例。如果您正苦於以下問題:C++ ObjectManager::render方法的具體用法?C++ ObjectManager::render怎麽用?C++ ObjectManager::render使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ObjectManager的用法示例。


在下文中一共展示了ObjectManager::render方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: Draw

void Draw()
{
	
	glClearColor(1.f, 1.f, 1.f, 1.f);
	glClearDepth(1.f);
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);

	mat4 cameraMatrix = esgiLookAt(camera.position, camera.position + camera.target, vec3(0.0, 1.0, 0.0));
	mat4 projectionMatrix = esgiPerspective(45, (float)((float)WINDOW_WIDTH/(float)WINDOW_HEIGHT), 0.01f, 10000.f);
	
	mat4 viewMatrix = esgiMultiplyMatrix(cameraMatrix, esgiRotateY(camera.orientation.y));
	mat4 modelviewMatrix;
	mat4 worldMatrix;
	modelviewMatrix.Identity();
	worldMatrix.Identity();
	modelviewMatrix = esgiMultiplyMatrix(viewMatrix, worldMatrix);

	esgiUtilsDrawAxes(modelviewMatrix,projectionMatrix,1.f);

	GLuint programObject = shader.GetProgram();
	glUseProgram(programObject);


	GLint position_attrib = glGetAttribLocation(programObject,"a_Position");

	GLint color_uniform = glGetUniformLocation(programObject, "u_Color");

	GLint texture_uniform = glGetUniformLocation(programObject, "u_UseTexture");

	GLint depthHall_uniform = glGetUniformLocation(programObject, "u_DepthHole");
	glUniform1f(depthHall_uniform, depthExplosion);

	GLint viewUniform = glGetUniformLocation(programObject, "u_ViewMatrix");
	glUniformMatrix4fv(viewUniform, 1, 0, &viewMatrix.I.x);

	mat4 uniformMatrix = esgiRotateX(0);
	GLint rotationUniform = glGetUniformLocation(programObject, "u_RotationMatrix");
	glUniformMatrix4fv(rotationUniform, 1, 0, &uniformMatrix.I.x);

	GLint projectionUniform = glGetUniformLocation(programObject, "u_ProjectionMatrix");
	glUniformMatrix4fv(projectionUniform, 1, 0, &projectionMatrix.I.x);

	worldMatrix.Identity();
	worldMatrix.T.set(0.f, 0.f, 0.f, 1.f); // Translate sur l'axe z
	GLint worldUnifrom = glGetUniformLocation(programObject, "u_WorldMatrix");
	glUniformMatrix4fv(worldUnifrom, 1, 0, &worldMatrix.I.x);
	
	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, groundTextureIds[0]);
	GLint textureUnit0 = glGetUniformLocation(programObject, "u_Texture1");
	glUniform1i(textureUnit0, 0);

	glActiveTexture(GL_TEXTURE1);
	glBindTexture(GL_TEXTURE_2D, groundTextureIds[1]);
	GLint textureUnit1 = glGetUniformLocation(programObject, "u_Texture2");
	glUniform1i(textureUnit1, 1);

	glEnableVertexAttribArray(position_attrib);
	objectManager.render(&position_attrib, &color_uniform, &texture_uniform);

	glDisableVertexAttribArray(position_attrib);

	
	//---------------= SKYBOX =--------------//
	programObject = shaderSkybox.GetProgram();
	glUseProgram(programObject);

	position_attrib = glGetAttribLocation(programObject,"a_Position");
	

	color_uniform = glGetUniformLocation(programObject, "u_Color");
	glUniform4f(color_uniform,0.f, 0.f, 0.f, 1.f);

	viewUniform = glGetUniformLocation(programObject, "u_ViewMatrix");
	glUniformMatrix4fv(viewUniform, 1, 0, &viewMatrix.I.x);

	rotationUniform = glGetUniformLocation(programObject, "u_RotationMatrix");
	glUniformMatrix4fv(rotationUniform, 1, 0, &uniformMatrix.I.x);

	GLuint uniformScale = glGetUniformLocation(programObject, "u_Scale");
	glUniform1f(uniformScale, scale);

	GLuint uniformFace = glGetUniformLocation(programObject, "u_Face");

	projectionUniform = glGetUniformLocation(programObject, "u_ProjectionMatrix");
	glUniformMatrix4fv(projectionUniform, 1, 0, &projectionMatrix.I.x);
	

	worldMatrix.Identity();
	worldMatrix.T.set(0.f, 0.f, 0.f, 1.f); // Translate sur l'axe z
	worldUnifrom = glGetUniformLocation(programObject, "u_WorldMatrix");
	glUniformMatrix4fv(worldUnifrom, 1, 0, &worldMatrix.I.x);


	for(int i = 0; i < 6; ++i)
	{
		glVertexAttribPointer(position_attrib, 3, GL_FLOAT, false, 0, &skybox[i].getListOfVertices()->at(0).x);
//.........這裏部分代碼省略.........
開發者ID:bibiGN,項目名稱:annualproject,代碼行數:101,代碼來源:main.cpp


注:本文中的ObjectManager::render方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。