00001 #ifndef OPENTISSUE_UTILITY_GL_GL_DRAW_STRING_H 00002 #define OPENTISSUE_UTILITY_GL_GL_DRAW_STRING_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 #include <string> 00015 00016 namespace OpenTissue 00017 { 00018 00019 namespace gl 00020 { 00021 00034 template<typename vector3_type> 00035 inline void DrawString(std::string const & str, vector3_type const & T,float width = 0.0f) 00036 { 00037 char const * text = str.c_str(); 00038 unsigned int length = str.length(); 00039 00040 float total_width = 0; 00041 for (unsigned int i = 0;i<=length;++i) 00042 total_width += glutStrokeWidth(GLUT_STROKE_ROMAN, text[i]);//--- what units are this working in??? 00043 00044 float aspect = 1.0; 00045 if(width>0) 00046 aspect = width/total_width; 00047 00048 glPushMatrix(); 00049 glTranslatef(T(0),T(1),T(2)); 00050 float magic = 0.005; //--- some magic because I cant figure out the units!!!! 00051 glScalef(magic,magic,magic); 00052 for (unsigned int i = 0;i<=length;++i) 00053 glutStrokeCharacter( GLUT_STROKE_ROMAN, text[i]); 00054 glPopMatrix(); 00055 } 00056 00057 } // namespace gl 00058 00059 } // namespace OpenTissue 00060 00061 //OPENTISSUE_UTILITY_GL_GL_DRAW_STRING_H 00062 #endif