本文整理汇总了C++中VertexBufferState::newDisplayList方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexBufferState::newDisplayList方法的具体用法?C++ VertexBufferState::newDisplayList怎么用?C++ VertexBufferState::newDisplayList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexBufferState
的用法示例。
在下文中一共展示了VertexBufferState::newDisplayList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: 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;
}
}
}