本文整理汇总了C++中Renderable::getMesh方法的典型用法代码示例。如果您正苦于以下问题:C++ Renderable::getMesh方法的具体用法?C++ Renderable::getMesh怎么用?C++ Renderable::getMesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Renderable
的用法示例。
在下文中一共展示了Renderable::getMesh方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isContainedInFrustum
bool Viewport::isContainedInFrustum(const Renderable& r) const {
AABB bb = r.getObject().transformAABB(r.getMesh()->getBounds());
Vector halfSize = (bb.max - bb.min) * 0.5f;
Vector worldPos = r.getObject().getWorldPosition();
//for each plane, check where the AABB is placed
for (auto&& i : range(4)) {
if (mWorldFrustumPlanes[i].getSide(worldPos, halfSize) < 0) {
return false;
}
}
return true;
}
示例2: 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
}