本文整理汇总了C++中VertexBufferState类的典型用法代码示例。如果您正苦于以下问题:C++ VertexBufferState类的具体用法?C++ VertexBufferState怎么用?C++ VertexBufferState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VertexBufferState类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: renderBufferObject
/* Render the leaf with buffer objects. */
void VertexBufferLeaf::renderBufferObject( VertexBufferState& state ) const
{
GLuint buffers[4];
for( int i = 0; i < 4; ++i )
buffers[i] =
state.getBufferObject( reinterpret_cast< const char* >(this) + i );
if( buffers[VERTEX_OBJECT] == state.INVALID ||
buffers[NORMAL_OBJECT] == state.INVALID ||
buffers[COLOR_OBJECT] == state.INVALID ||
buffers[INDEX_OBJECT] == state.INVALID )
setupRendering( state, buffers );
if( state.useColors() )
{
glBindBuffer( GL_ARRAY_BUFFER, buffers[COLOR_OBJECT] );
glColorPointer( 4, GL_UNSIGNED_BYTE, 0, 0 );
}
glBindBuffer( GL_ARRAY_BUFFER, buffers[NORMAL_OBJECT] );
glNormalPointer( GL_FLOAT, 0, 0 );
glBindBuffer( GL_ARRAY_BUFFER, buffers[VERTEX_OBJECT] );
glVertexPointer( 3, GL_FLOAT, 0, 0 );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, buffers[INDEX_OBJECT] );
glDrawElements( GL_TRIANGLES, GLsizei( _indexLength ), GL_UNSIGNED_SHORT, 0 );
}
开发者ID:MichaelVlad,项目名称:Equalizer,代码行数:26,代码来源:vertexBufferLeaf.cpp
示例2: drawBoundingSphere
void VertexBufferBase::drawBoundingSphere(VertexBufferState& state ) const
{
GLuint displayList = state.getDisplayList( &_boundingSphere );
if( displayList == state.INVALID )
{
displayList = state.newDisplayList( &_boundingSphere );
glNewList( displayList, GL_COMPILE );
const float x = _boundingSphere.x();
const float y = _boundingSphere.y();
const float z = _boundingSphere.z();
const float x1 = x - _boundingSphere.w();
const float x2 = x + _boundingSphere.w();
const float y1 = y - _boundingSphere.w();
const float y2 = y + _boundingSphere.w();
const float z1 = z - _boundingSphere.w();
const float z2 = z + _boundingSphere.w();
const float size = _boundingSphere.w();
glBegin( GL_QUADS );
glNormal3f( 1.0f, 0.0f, 0.0f );
glVertex3f( x1, y - size, z - size );
glVertex3f( x1, y + size, z - size );
glVertex3f( x1, y + size, z + size );
glVertex3f( x1, y - size, z + size );
glNormal3f( -1.0f, 0.0f, 0.0f );
glVertex3f( x2, y - size, z - size );
glVertex3f( x2, y - size, z + size );
glVertex3f( x2, y + size, z + size );
glVertex3f( x2, y + size, z - size );
glNormal3f( 0.0f, -1.0f, 0.0f );
glVertex3f( x - size, y2, z - size );
glVertex3f( x + size, y2, z - size );
glVertex3f( x + size, y2, z + size );
glVertex3f( x - size, y2, z + size );
glNormal3f( 0.0f, 1.0f, 0.0f );
glVertex3f( x - size, y1, z - size );
glVertex3f( x - size, y1, z + size );
glVertex3f( x + size, y1, z + size );
glVertex3f( x + size, y1, z - size );
glNormal3f( 0.0f, 0.0f, -1.0f );
glVertex3f( x - size, y - size, z2 );
glVertex3f( x - size, y + size, z2 );
glVertex3f( x + size, y + size, z2 );
glVertex3f( x + size, y - size, z2 );
glNormal3f( 0.0f, 0.0f, 1.0f );
glVertex3f( x - size, y - size, z1 );
glVertex3f( x + size, y - size, z1 );
glVertex3f( x + size, y + size, z1 );
glVertex3f( x - size, y + size, z1 );
glEnd();
glEndList();
}
glCallList( displayList );
}
开发者ID:Angels-group,项目名称:Equalizer,代码行数:60,代码来源:vertexBufferBase.cpp
示例3: renderDisplayList
/* Render the leaf with a display list. */
inline
void VertexBufferLeaf::renderDisplayList( VertexBufferState& state ) const
{
char* key = (char*)( this );
if( state.useColors( ))
++key;
GLuint displayList = state.getDisplayList( key );
if( displayList == state.INVALID )
setupRendering( state, &displayList );
glCallList( displayList );
}
开发者ID:MichaelVlad,项目名称:Equalizer,代码行数:15,代码来源:vertexBufferLeaf.cpp
示例4: setupRendering
/* Set up rendering of the leaf nodes. */
void VertexBufferLeaf::setupRendering( VertexBufferState& state,
GLuint* data ) const
{
switch( state.getRenderMode() )
{
case RENDER_MODE_IMMEDIATE:
break;
case RENDER_MODE_BUFFER_OBJECT:
{
const char* charThis = reinterpret_cast< const char* >( this );
if( data[VERTEX_OBJECT] == state.INVALID )
data[VERTEX_OBJECT] = state.newBufferObject( charThis + 0 );
glBindBuffer( GL_ARRAY_BUFFER, data[VERTEX_OBJECT] );
glBufferData( GL_ARRAY_BUFFER, _vertexLength * sizeof( Vertex ),
&_globalData.vertices[_vertexStart], GL_STATIC_DRAW );
if( data[NORMAL_OBJECT] == state.INVALID )
data[NORMAL_OBJECT] = state.newBufferObject( charThis + 1 );
glBindBuffer( GL_ARRAY_BUFFER, data[NORMAL_OBJECT] );
glBufferData( GL_ARRAY_BUFFER, _vertexLength * sizeof( Normal ),
&_globalData.normals[_vertexStart], GL_STATIC_DRAW );
if( data[COLOR_OBJECT] == state.INVALID )
data[COLOR_OBJECT] = state.newBufferObject( charThis + 2 );
if( state.useColors() )
{
glBindBuffer( GL_ARRAY_BUFFER, data[COLOR_OBJECT] );
glBufferData( GL_ARRAY_BUFFER, _vertexLength * sizeof( Color ),
&_globalData.colors[_vertexStart], GL_STATIC_DRAW );
}
if( data[INDEX_OBJECT] == state.INVALID )
data[INDEX_OBJECT] = state.newBufferObject( charThis + 3 );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, data[INDEX_OBJECT] );
glBufferData( GL_ELEMENT_ARRAY_BUFFER,
_indexLength * sizeof( ShortIndex ),
&_globalData.indices[_indexStart], GL_STATIC_DRAW );
break;
}
case RENDER_MODE_DISPLAY_LIST:
default:
{
if( data[0] == state.INVALID )
{
char* key = (char*)( this );
if( state.useColors( ))
++key;
data[0] = state.newDisplayList( key );
}
glNewList( data[0], GL_COMPILE );
renderImmediate( state );
glEndList();
break;
}
}
}
开发者ID:MichaelVlad,项目名称:Equalizer,代码行数:60,代码来源:vertexBufferLeaf.cpp
示例5: draw
/* Draw the node by rendering the children. */
void VertexBufferNode::draw( VertexBufferState& state ) const
{
if ( state.stopRendering( ))
return;
_left->draw( state );
_right->draw( state );
}
开发者ID:hernando,项目名称:Equalizer,代码行数:9,代码来源:vertexBufferNode.cpp
示例6: _beginRendering
/* Set up the common OpenGL state for rendering of all nodes. */
void VertexBufferRoot::_beginRendering( VertexBufferState& state ) const
{
state.resetRegion();
switch( state.getRenderMode() )
{
#ifdef GL_ARB_vertex_buffer_object
case RENDER_MODE_BUFFER_OBJECT:
glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT );
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_NORMAL_ARRAY );
if( state.useColors() )
glEnableClientState( GL_COLOR_ARRAY );
#endif
case RENDER_MODE_DISPLAY_LIST:
case RENDER_MODE_IMMEDIATE:
default:
;
}
}
开发者ID:oliver-e,项目名称:Equalizer,代码行数:20,代码来源:vertexBufferRoot.cpp
示例7: draw
/* Draw the leaf. */
void VertexBufferLeaf::draw( VertexBufferState& state ) const
{
if ( state.stopRendering( ))
return;
switch( state.getRenderMode() )
{
case RENDER_MODE_IMMEDIATE:
renderImmediate( state );
return;
case RENDER_MODE_BUFFER_OBJECT:
renderBufferObject( state );
return;
case RENDER_MODE_DISPLAY_LIST:
default:
renderDisplayList( state );
return;
}
}
开发者ID:MichaelVlad,项目名称:Equalizer,代码行数:20,代码来源:vertexBufferLeaf.cpp
示例8: renderImmediate
/* Render the leaf with immediate mode primitives or vertex arrays. */
inline
void VertexBufferLeaf::renderImmediate( VertexBufferState& state ) const
{
glBegin( GL_TRIANGLES );
for( Index offset = 0; offset < _indexLength; ++offset )
{
const Index i =_vertexStart + _globalData.indices[_indexStart + offset];
if( state.useColors() )
glColor3ubv( &_globalData.colors[i][0] );
glNormal3fv( &_globalData.normals[i][0] );
glVertex3fv( &_globalData.vertices[i][0] );
}
glEnd();
}
开发者ID:roberthauck,项目名称:Equalizer,代码行数:15,代码来源:vertexBufferLeaf.cpp
示例9: _endRendering
/* Tear down the common OpenGL state for rendering of all nodes. */
void VertexBufferRoot::_endRendering( VertexBufferState& state ) const
{
switch( state.getRenderMode() )
{
#ifdef GL_ARB_vertex_buffer_object
case RENDER_MODE_BUFFER_OBJECT:
{
// deactivate VBO and EBO use
#define glewGetContext state.glewGetContext
glBindBuffer( GL_ARRAY_BUFFER_ARB, 0);
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
glPopClientAttrib();
}
#endif
case RENDER_MODE_DISPLAY_LIST:
case RENDER_MODE_IMMEDIATE:
default:
;
}
}
开发者ID:oliver-e,项目名称:Equalizer,代码行数:21,代码来源:vertexBufferRoot.cpp
示例10: renderImmediate
/* Render the leaf with immediate mode primitives or vertex arrays. */
inline
void VertexBufferLeaf::renderImmediate( VertexBufferState& state ) const
{
glBegin( GL_TRIANGLES );
for( Index offset = 0; offset < _indexLength; ++offset )
{
const Index i =_vertexStart + _globalData.indices[_indexStart + offset];
if( state.useColors() )
glColor4ubv( &_globalData.colors[i][0] );
glNormal3fv( &_globalData.normals[i][0] );
glVertex3fv( &_globalData.vertices[i][0] );
}
glEnd();
// if( state.useColors() )
// glColorPointer( 4, GL_UNSIGNED_BYTE, 0,
// &_globalData.colors[_vertexStart] );
// glNormalPointer( GL_FLOAT, 0, &_globalData.normals[_vertexStart] );
// glVertexPointer( 3, GL_FLOAT, 0, &_globalData.vertices[_vertexStart] );
// glDrawElements( GL_TRIANGLES, _indexLength, GL_UNSIGNED_SHORT,
// &_globalData.indices[_indexStart] );
}
开发者ID:MichaelVlad,项目名称:Equalizer,代码行数:23,代码来源:vertexBufferLeaf.cpp
示例11: cullDraw
// #define LOGCULL
void VertexBufferRoot::cullDraw( VertexBufferState& state ) const
{
_beginRendering( state );
#ifdef LOGCULL
size_t verticesRendered = 0;
size_t verticesOverlap = 0;
#endif
const Range& range = state.getRange();
FrustumCuller culler;
culler.setup( state.getProjectionModelViewMatrix( ));
// start with root node
std::vector< const mesh::VertexBufferBase* > candidates;
candidates.push_back( this );
while( !candidates.empty() )
{
if( state.stopRendering( ))
return;
const mesh::VertexBufferBase* treeNode = candidates.back();
candidates.pop_back();
// completely out of range check
if( treeNode->getRange()[0] >= range[1] ||
treeNode->getRange()[1] < range[0] )
{
continue;
}
// bounding sphere view frustum culling
const vmml::Visibility visibility = state.useFrustumCulling() ?
culler.test_sphere( treeNode->getBoundingSphere( )) :
vmml::VISIBILITY_FULL;
switch( visibility )
{
case vmml::VISIBILITY_FULL:
// if fully visible and fully in range, render it
if( treeNode->getRange()[0] >= range[0] &&
treeNode->getRange()[1] < range[1] )
{
treeNode->draw( state );
//treeNode->drawBoundingSphere( state );
#ifdef LOGCULL
verticesRendered += treeNode->getNumberOfVertices();
#endif
break;
}
// partial range, fall through to partial visibility
case vmml::VISIBILITY_PARTIAL:
{
const mesh::VertexBufferBase* left = treeNode->getLeft();
const mesh::VertexBufferBase* right = treeNode->getRight();
if( !left && !right )
{
if( treeNode->getRange()[0] >= range[0] )
{
treeNode->draw( state );
//treeNode->drawBoundingSphere( state );
#ifdef LOGCULL
verticesRendered += treeNode->getNumberOfVertices();
if( visibility == vmml::VISIBILITY_PARTIAL )
verticesOverlap += treeNode->getNumberOfVertices();
#endif
}
// else drop, to be drawn by 'previous' channel
}
else
{
if( left )
candidates.push_back( left );
if( right )
candidates.push_back( right );
}
break;
}
case vmml::VISIBILITY_NONE:
// do nothing
break;
}
}
_endRendering( state );
#ifdef LOGCULL
const size_t verticesTotal = model->getNumberOfVertices();
MESHINFO
<< getName() << " rendered " << verticesRendered * 100 / verticesTotal
<< "% of model, overlap <= " << verticesOverlap * 100 / verticesTotal
<< "%" << std::endl;
#endif
}
开发者ID:oliver-e,项目名称:Equalizer,代码行数:97,代码来源:vertexBufferRoot.cpp
注:本文中的VertexBufferState类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论