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


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

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


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

示例1: renderElement

void Renderer::renderElement( Viewport& viewport, Renderable& elem )
{
	DEBUG_ASSERT( frameStarted, "Tried to render an element but the frame wasn't started" );
	DEBUG_ASSERT(elem.getMesh()->isLoaded(), "Rendering with a mesh with no GPU data!");
	DEBUG_ASSERT(elem.getMesh()->getVertexCount() > 0, "Rendering a mesh with no vertices");

#ifndef PUBLISH
	frameVertexCount += elem.getMesh()->getVertexCount();
	frameTriCount += elem.getMesh()->getPrimitiveCount();

	//each renderable is a single batch
	++frameBatchCount;
#endif // !PUBLISH
	
	currentState.world = elem.getWorldTransform();
	currentState.worldView = currentState.view * currentState.world;

	glMatrixMode(GL_MODELVIEW);
	glLoadMatrixf( glm::value_ptr( currentState.worldView ) );
	
#ifdef DOJO_SHADERS_AVAILABLE
	if( elem.getShader() )
	{
		currentState.worldViewProjection = currentState.projection * currentState.worldView;
		elem.getShader()->use( elem );
	}
	else
		glUseProgram( 0 );
#endif
		
	//I'm not sure this actually makes sense
#ifndef USING_OPENGLES
	glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT );
#endif
	glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, (float*)(&elem.color) );
	
	glEnable( GL_COLOR_MATERIAL );

	elem.commitChanges();

	static const GLenum glModeMap[] = {
		GL_TRIANGLE_STRIP, //TriangleStrip,
		GL_TRIANGLES, //TriangleList,
		GL_LINE_STRIP, //LineStrip,
		GL_LINES, //LineList
		GL_POINTS
	};

	Mesh* m = elem.getMesh();
	GLenum mode = glModeMap[(byte)m->getTriangleMode()];

	if( !m->isIndexed() )
		glDrawArrays( mode, 0, m->getVertexCount() );
	else {
		DEBUG_ASSERT(m->getIndexCount() > 0, "Rendering an indexed mesh with no indices");
		glDrawElements(mode, m->getIndexCount(), m->getIndexGLType(), 0);  //on OpenGLES, we have max 65536 indices!!!
	}

#ifndef DOJO_DISABLE_VAOS
	glBindVertexArray( 0 );
#endif

#ifdef DOJO_SHADERS_AVAILABLE
	//HACK //TODO remove fixed function pipeline (it breaks if generic arrays are set)
	if( elem.getShader() )
	{
		for( auto& attr : elem.getShader()->getAttributes() )
			glDisableVertexAttribArray( attr.second.location );
	}
#endif
}
开发者ID:hjeldin,项目名称:dojo,代码行数:71,代码来源:Renderer.cpp


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