예제 #1
0
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
0
/*  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 );
}