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


C++ Renderable::Render方法代码示例

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


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

示例1: Render

void OGLWindow::Render()
{
	m_skyBox->SetPosition(*m_camera->GetCameraPosition());

	m_rotation += 1.0f;

	glm::mat4 inv;

	float modelview[16];
	

	Renderable* prenderable = static_cast<Renderable*>(m_mesh);

	Renderable* plane = static_cast<Renderable*>(m_plane);


	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	glLoadIdentity();

	m_skyBoxShader->ActivateShaderProgram();

	glGetFloatv(GL_MODELVIEW_MATRIX, modelview);

	glUniformMatrix4fv(0, 1, GL_FALSE, modelview);
	glUniformMatrix4fv(1, 1, GL_FALSE, &m_camera->GetProjectionMatrix()[0][0]);
	glUniformMatrix4fv(3, 1, GL_FALSE, &m_camera->GetViewMatrix()[0][0]);

	//Camera position to vertex shader
	glm::vec3 camPosition = *m_camera->GetCameraPosition();

	glUniform4f(4, camPosition[0], camPosition[1], camPosition[2], 1.0f);

	glDisable(GL_DEPTH_TEST);
	m_skyBox->Render();
	glEnable(GL_DEPTH_TEST);

	m_shader->ActivateShaderProgram();
	
	
	glTranslatef( -148.0f, 8.0f, -10.0f );
	glRotatef(0.20f, 0.0f, 1.0f, 0.0f);
	/*glRotatef( m_euler[1], 0.0, 1.0, 0.0 );
	glRotatef( m_euler[2], 0.0, 0.0, 1.0 );*/

	glGetFloatv( GL_MODELVIEW_MATRIX, modelview );
	glUniformMatrix4fv(0, 1, GL_FALSE, modelview);
	glUniformMatrix4fv(1, 1, GL_FALSE, &m_camera->GetProjectionMatrix()[0][0]);
	glUniformMatrix4fv(3, 1, GL_FALSE, &m_camera->GetViewMatrix()[0][0]);

	
	inv = glm::inverseTranspose(glm::mat4(modelview[0]));

	glUniformMatrix4fv(10, 1, GL_FALSE, &inv[0][0]);

	camPosition = *m_camera->GetCameraPosition();


	glUniform4f(4, camPosition[0], camPosition[1], camPosition[2], 1.0f);

	prenderable->Render();

	//load terrain
	glLoadIdentity();
	glTranslatef(0.0f, -300.0f, 0.0f);
	glGetFloatv(GL_MODELVIEW_MATRIX, modelview);

	glUniformMatrix4fv(0, 1, GL_FALSE, modelview);
	inv = glm::inverseTranspose(glm::mat4(modelview[0]));

	glUniformMatrix4fv(10, 1, GL_FALSE, &inv[0][0]);

	m_terrain->Render();

	//load plane
	glLoadIdentity();
	glTranslatef(20.0f, 200.0f, 100.0f);
	glRotatef(m_rotation, 0.5f, 1.0f, 0.0f);
	glTranslatef(0.5f, -100.0f, -200.0f);
	glGetFloatv(GL_MODELVIEW_MATRIX, modelview);

	glUniformMatrix4fv(0, 1, GL_FALSE, modelview);
	inv = glm::inverseTranspose(glm::mat4(modelview[0]));

	glUniformMatrix4fv(10, 1, GL_FALSE, &inv[0][0]);

	plane->Render();

	KeyPress();

	POINT mouse;
	GetCursorPos(&mouse);
	int xPos = mouse.x;
	int yPos = mouse.y;
	int xAxis = (m_width / 2) - xPos;
	int yAxis = (m_height / 2) - yPos;

	//smoothes the look sensitivity
	float i = 0.05f;

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


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