00001 #ifndef OPENTISSUE_UTILITY_GL_GL_DRAW_SPHERE_H 00002 #define OPENTISSUE_UTILITY_GL_GL_DRAW_SPHERE_H 00003 // 00004 // OpenTissue Template Library 00005 // - A generic toolbox for physics-based modeling and simulation. 00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen. 00007 // 00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php 00009 // 00010 #include <OpenTissue/configuration.h> 00011 00012 #include <OpenTissue/utility/gl/gl.h> 00013 00014 namespace OpenTissue 00015 { 00016 00017 namespace gl 00018 { 00019 00026 template<typename sphere_type> 00027 inline void DrawSphere(sphere_type const & sphere, bool wireframe = false) 00028 { 00029 typedef typename sphere_type::real_type real_type; 00030 typedef typename sphere_type::vector3_type vector3_type; 00031 00032 real_type const & r = sphere.radius(); 00033 vector3_type const & c = sphere.center(); 00034 00035 glPolygonMode(GL_FRONT_AND_BACK,(wireframe?GL_LINE:GL_FILL)); 00036 GLUquadricObj* qobj = gluNewQuadric(); 00037 glPushMatrix(); 00038 glTranslatef( 00039 (GLfloat)c[0], 00040 (GLfloat)c[1], 00041 (GLfloat)c[2] 00042 ); 00043 gluSphere(qobj,r,32,32); 00044 glPopMatrix(); 00045 gluDeleteQuadric(qobj); 00046 glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); 00047 } 00048 00049 } // namespace gl 00050 00051 } // namespace OpenTissue 00052 00053 //OPENTISSUE_UTILITY_GL_GL_DRAW_SPHERE_H 00054 #endif