vertexBufferBase.cpp

00001 
00002 /* Copyright (c) 2008-2009, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016  */
00017 
00018 #include "vertexBufferBase.h"
00019 #include "vertexBufferState.h"
00020 
00021 namespace mesh
00022 {
00023 void VertexBufferBase::renderBoundingSphere(VertexBufferState& state ) const
00024 {
00025     GLuint displayList = state.getDisplayList( &_boundingSphere );
00026 
00027     if( displayList == state.INVALID )
00028     {
00029         displayList = state.newDisplayList( &_boundingSphere );
00030         glNewList( displayList, GL_COMPILE );
00031 
00032         const float x  = _boundingSphere.x();
00033         const float y  = _boundingSphere.y();
00034         const float z  = _boundingSphere.z();
00035         const float x1 = x - _boundingSphere.w();
00036         const float x2 = x + _boundingSphere.w();
00037         const float y1 = y - _boundingSphere.w();
00038         const float y2 = y + _boundingSphere.w();
00039         const float z1 = z - _boundingSphere.w();
00040         const float z2 = z + _boundingSphere.w();
00041         const float size = _boundingSphere.w();
00042 
00043 //        glDisable( GL_LIGHTING );
00044         glBegin( GL_QUADS );
00045         glNormal3f( 1.0f, 0.0f, 0.0f );
00046         glVertex3f( x1, y - size, z - size );
00047         glVertex3f( x1, y + size, z - size );
00048         glVertex3f( x1, y + size, z + size );
00049         glVertex3f( x1, y - size, z + size );
00050         glNormal3f( -1.0f, 0.0f, 0.0f );
00051         glVertex3f( x2, y - size, z - size );
00052         glVertex3f( x2, y - size, z + size );
00053         glVertex3f( x2, y + size, z + size );
00054         glVertex3f( x2, y + size, z - size );
00055 
00056         glNormal3f( 0.0f, -1.0f, 0.0f );
00057         glVertex3f( x - size, y2, z - size );
00058         glVertex3f( x + size, y2, z - size );
00059         glVertex3f( x + size, y2, z + size );
00060         glVertex3f( x - size, y2, z + size );
00061         glNormal3f( 0.0f, 1.0f, 0.0f );
00062         glVertex3f( x - size, y1, z - size );
00063         glVertex3f( x - size, y1, z + size );
00064         glVertex3f( x + size, y1, z + size );
00065         glVertex3f( x + size, y1, z - size );
00066 
00067         glNormal3f( 0.0f, 0.0f, -1.0f );
00068         glVertex3f( x - size, y - size, z2 );
00069         glVertex3f( x - size, y + size, z2 );
00070         glVertex3f( x + size, y + size, z2 );
00071         glVertex3f( x + size, y - size, z2 );
00072         glNormal3f( 0.0f, 0.0f, 1.0f );
00073         glVertex3f( x - size, y - size, z1 );
00074         glVertex3f( x + size, y - size, z1 );
00075         glVertex3f( x + size, y + size, z1 );
00076         glVertex3f( x - size, y + size, z1 );
00077         glEnd();
00078 //        glEnable( GL_LIGHTING );
00079 
00080         glEndList();
00081     }
00082 
00083     glCallList( displayList );
00084 }
00085 }
Generated on Mon Aug 10 18:58:41 2009 for Equalizer 0.9 by  doxygen 1.5.8