00001 00004 /***************************************************************************** 00005 ** Includes 00006 *****************************************************************************/ 00007 00008 #include "../../include/qglv/gl/headers.hpp" 00009 #include "../../include/qglv/primitives/text.hpp" 00010 00011 // must be after including gl/headers.hpp - can we get rid of this dep.? 00012 #include <GL/glut.h> 00013 00014 /***************************************************************************** 00015 ** Namespaces 00016 *****************************************************************************/ 00017 00018 namespace qglv { 00019 00020 /***************************************************************************** 00021 ** Implementation 00022 *****************************************************************************/ 00023 00024 void text( const std::string & str, const Eigen::Vector3f & location ) 00025 { 00026 static bool glut_initialised(false); 00027 00028 if( !glut_initialised ) 00029 { 00030 int argc=1; 00031 char * argv[1]; 00032 argv[0] = (char *)"glServer"; 00033 00034 glutInit(&argc, argv); 00035 glut_initialised = true; 00036 } 00037 // if we wanted to centre align, however we don't seem to have gluBitmapWidth 00038 // float length = 0.0; 00039 // for ( const char& c : str ) { 00040 // length += gluBitmapWidth(GLUT_BITMAP_HELVETICA_12); 00041 // } 00042 glRasterPos3f( location.x(), location.y(), location.z() ); 00043 00044 for( int i(0); i < str.size(); i++) 00045 { 00046 glutBitmapCharacter( GLUT_BITMAP_HELVETICA_12, str[i] ); 00047 } 00048 } 00049 00050 /***************************************************************************** 00051 ** Trailers 00052 *****************************************************************************/ 00053 00054 } // namespace qglv