Equalizer  1.4.1
seqPly/vertexBufferBase.cpp
00001 
00002 /* Copyright (c) 2008-2009, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *
00007  * - Redistributions of source code must retain the above copyright notice, this
00008  *   list of conditions and the following disclaimer.
00009  * - Redistributions in binary form must reproduce the above copyright notice,
00010  *   this list of conditions and the following disclaimer in the documentation
00011  *   and/or other materials provided with the distribution.
00012  * - Neither the name of Eyescale Software GmbH nor the names of its
00013  *   contributors may be used to endorse or promote products derived from this
00014  *   software without specific prior written permission.
00015  *
00016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00019  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00020  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00021  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00022  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00025  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00026  * POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00029 #include "vertexBufferBase.h"
00030 #include "vertexBufferState.h"
00031 
00032 namespace mesh
00033 {
00034 void VertexBufferBase::drawBoundingSphere(VertexBufferState& state ) const
00035 {
00036     GLuint displayList = state.getDisplayList( &_boundingSphere );
00037 
00038     if( displayList == state.INVALID )
00039     {
00040         displayList = state.newDisplayList( &_boundingSphere );
00041         glNewList( displayList, GL_COMPILE );
00042 
00043         const float x  = _boundingSphere.x();
00044         const float y  = _boundingSphere.y();
00045         const float z  = _boundingSphere.z();
00046         const float x1 = x - _boundingSphere.w();
00047         const float x2 = x + _boundingSphere.w();
00048         const float y1 = y - _boundingSphere.w();
00049         const float y2 = y + _boundingSphere.w();
00050         const float z1 = z - _boundingSphere.w();
00051         const float z2 = z + _boundingSphere.w();
00052         const float size = _boundingSphere.w();
00053 
00054 //        glDisable( GL_LIGHTING );
00055         glBegin( GL_QUADS );
00056             glNormal3f( 1.0f, 0.0f, 0.0f );
00057             glVertex3f( x1, y - size, z - size );
00058             glVertex3f( x1, y + size, z - size );
00059             glVertex3f( x1, y + size, z + size );
00060             glVertex3f( x1, y - size, z + size );
00061             glNormal3f( -1.0f, 0.0f, 0.0f );
00062             glVertex3f( x2, y - size, z - size );
00063             glVertex3f( x2, y - size, z + size );
00064             glVertex3f( x2, y + size, z + size );
00065             glVertex3f( x2, y + size, z - size );
00066 
00067             glNormal3f( 0.0f, -1.0f, 0.0f );
00068             glVertex3f( x - size, y2, z - size );
00069             glVertex3f( x + size, y2, z - size );
00070             glVertex3f( x + size, y2, z + size );
00071             glVertex3f( x - size, y2, z + size );
00072             glNormal3f( 0.0f, 1.0f, 0.0f );
00073             glVertex3f( x - size, y1, z - size );
00074             glVertex3f( x - size, y1, z + size );
00075             glVertex3f( x + size, y1, z + size );
00076             glVertex3f( x + size, y1, z - size );
00077 
00078             glNormal3f( 0.0f, 0.0f, -1.0f );
00079             glVertex3f( x - size, y - size, z2 );
00080             glVertex3f( x - size, y + size, z2 );
00081             glVertex3f( x + size, y + size, z2 );
00082             glVertex3f( x + size, y - size, z2 );
00083             glNormal3f( 0.0f, 0.0f, 1.0f );
00084             glVertex3f( x - size, y - size, z1 );
00085             glVertex3f( x + size, y - size, z1 );
00086             glVertex3f( x + size, y + size, z1 );
00087             glVertex3f( x - size, y + size, z1 );
00088         glEnd();
00089 //        glEnable( GL_LIGHTING );
00090 
00091         glEndList();
00092     }
00093 
00094     glCallList( displayList );
00095 }
00096 }
Generated on Mon Nov 26 2012 14:41:49 for Equalizer 1.4.1 by  doxygen 1.7.6.1