Changeset 18550
- Timestamp:
- 04/12/06 09:01:57 (3 years ago)
- Files:
-
- juggler/branches/2.0/modules/vrjuggler/test/Draw/OGL/perfAddon/PerfProbe.cpp (modified) (3 diffs)
- juggler/branches/2.0/modules/vrjuggler/test/Draw/OGL/perfAddon/PerfProbe.h (modified) (2 diffs)
- juggler/branches/2.0/modules/vrjuggler/test/Draw/OGL/perfAddon/Text.cpp (modified) (4 diffs)
- juggler/branches/2.0/modules/vrjuggler/test/Draw/OGL/perfAddon/Text.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
juggler/branches/2.0/modules/vrjuggler/test/Draw/OGL/perfAddon/PerfProbe.cpp
r17820 r18550 46 46 47 47 #include <vrj/Kernel/Kernel.h> 48 #include <vpr/Util/Debug.h> 48 49 49 50 //#include <boost/format.hpp> 50 51 51 namespace52 {53 template<class OutIt>54 void splitStr(55 const std::string& s,56 const std::string& sep,57 OutIt dest)58 {59 std::string::size_type left = s.find_first_not_of( sep );60 std::string::size_type right = s.find_first_of( sep, left );61 while( left < right )62 {63 *dest = s.substr( left, right-left );64 ++dest;65 left = s.find_first_not_of( sep, right );66 right = s.find_first_of( sep, left );67 }68 }69 70 //std::string s = "apple, orange, cherry, peach, grapefruit, cantalope,watermelon";71 72 //std::vector<std::string> v;73 //split( s, " ,", std::back_inserter(v) );74 75 }76 52 77 53 … … 117 93 { mOverlayTextStream << " "; } 118 94 mOverlayTextStream << (*prof_node).getName() << " " << (*prof_node).getSTA().msecf() << std::endl; 119 } 120 95 } 121 96 } 122 97 … … 137 112 138 113 void PerfProbe::drawOverlayText() 139 { 140 const float font_height(10.0f); 141 const float font_h_spacing(font_height*1.3f); 142 float win_height(1000); 143 float win_width(win_height * 1.4f); 144 114 { 145 115 std::string overlay_text = mOverlayTextStream.str(); 146 std::vector<std::string> overlay_lines; 147 splitStr(overlay_text,"\n",std::back_inserter(overlay_lines)); 148 149 float needed_h = font_h_spacing*float(overlay_lines.size()); 150 if(needed_h > win_height) 151 { 152 win_height = needed_h * 1.1f; 153 win_width = win_height * 1.4f; 154 } 155 156 glMatrixMode( GL_PROJECTION ); 157 glPushMatrix(); 158 glLoadIdentity(); 159 glOrtho( 0.0, win_width, 0.0, win_height, -1.0, 1.0); // Setup virtual space 1000, 1000 160 161 glMatrixMode( GL_MODELVIEW ); 162 glPushMatrix(); 163 glLoadIdentity(); 164 165 glDisable(GL_DEPTH_TEST); 166 167 /* 168 glBegin(GL_TRIANGLES); 169 glColor3f(1.0, 0.0, 0); 170 glVertex3f(100,100,-0.5); 171 glColor3f(0,1,0); 172 glVertex3f(900,100,-0.5); 173 glColor3f(0,0,1); 174 glVertex3f(450,800,-0.5); 175 glEnd(); 176 */ 177 //Text::getSingleton()->drawString(Text::StrokeFont, std::string("No Translation")); 178 116 179 117 glColor3f(1.0,1.0,0.0); 180 glTranslatef(10, win_height-30, 0); 181 //float num_lines(overlay_lines.size()); 182 183 for (unsigned l=0;l<overlay_lines.size();++l) 184 { 185 glPushMatrix(); 186 glTranslatef(0,-font_h_spacing*float(l), 0); 187 Text::getSingleton()->drawString(Text::StrokeFont, overlay_lines[l]); 188 glPopMatrix(); 189 } 190 191 glEnable(GL_DEPTH_TEST); 192 193 glMatrixMode(GL_PROJECTION); 194 glPopMatrix(); 195 glMatrixMode( GL_MODELVIEW); 196 glPopMatrix(); 118 mText->drawTextBlock(overlay_text); 197 119 } 198 120 juggler/branches/2.0/modules/vrjuggler/test/Draw/OGL/perfAddon/PerfProbe.h
r16525 r18550 38 38 #include <vpr/Util/Interval.h> 39 39 #include <sstream> 40 #include <vrj/Draw/OGL/GlContextData.h> 41 #include <Text.h> 40 42 41 43 … … 72 74 73 75 std::stringstream mOverlayTextStream; /**< Text to write out each frame. */ 76 std::string mOverlayTextToDraw; 77 vrj::GlContextData<Text> mText; /**< Context specific copy of text. */ 74 78 75 79 std::deque<float> mFrameRateHistory; juggler/branches/2.0/modules/vrjuggler/test/Draw/OGL/perfAddon/Text.cpp
r16435 r18550 12 12 ****************** <aqua heading END do not edit this line> ******************/ 13 13 #include "Text.h" 14 #include <vector> 15 #include <string> 16 17 namespace 18 { 19 template<class OutIt> 20 void splitStr( 21 const std::string& s, 22 const std::string& sep, 23 OutIt dest) 24 { 25 std::string::size_type left = s.find_first_not_of( sep ); 26 std::string::size_type right = s.find_first_of( sep, left ); 27 while( left < right ) 28 { 29 *dest = s.substr( left, right-left ); 30 ++dest; 31 left = s.find_first_not_of( sep, right ); 32 right = s.find_first_of( sep, left ); 33 } 34 } 35 36 //std::string s = "apple, orange, cherry, peach, grapefruit, cantalope,watermelon"; 37 38 //std::vector<std::string> v; 39 //split( s, " ,", std::back_inserter(v) ); 40 41 } 14 42 15 43 Text *Text::theText = NULL; … … 51 79 } 52 80 53 // Force singleton54 void *Text::operator new( size_t size )55 {56 if( theText == NULL )57 theText = (Text *)malloc( size );58 return (void *)theText;59 }60 81 61 82 Text *Text::getSingleton() … … 13757 13778 GLuint base = fontmap[font]; 13758 13779 if( base == 0 ) 13759 base = loadFont(font);13780 { base = loadFont(font); } 13760 13781 glPushAttrib(GL_LIST_BIT); 13761 13782 glListBase(base); … … 13763 13784 glPopAttrib(); 13764 13785 } 13786 13787 void Text::drawTextBlock(std::string text, const float xPosFactor, const float yPosFactor, 13788 float fontHeight, 13789 float winHeight, float winWidth) 13790 { 13791 const float font_h_spacing(fontHeight*1.3f); 13792 13793 std::vector<std::string> text_lines; 13794 splitStr(text,"\n",std::back_inserter(text_lines)); 13795 13796 float needed_h = font_h_spacing*float(text_lines.size()); 13797 if(needed_h > winHeight) 13798 { 13799 winHeight = needed_h * 1.1f; 13800 winWidth = winHeight * 1.4f; 13801 } 13802 13803 glMatrixMode( GL_PROJECTION ); 13804 glPushMatrix(); 13805 glLoadIdentity(); 13806 glOrtho( 0.0, winWidth, 0.0, winHeight, -1.0, 1.0); // Setup virtual space 1000, 1000 13807 13808 glMatrixMode( GL_MODELVIEW ); 13809 glPushMatrix(); 13810 glLoadIdentity(); 13811 13812 glDisable(GL_DEPTH_TEST); 13813 13814 /* 13815 glBegin(GL_TRIANGLES); 13816 glColor3f(1.0, 0.0, 0); 13817 glVertex3f(100,100,-0.5); 13818 glColor3f(0,1,0); 13819 glVertex3f(900,100,-0.5); 13820 glColor3f(0,0,1); 13821 glVertex3f(450,800,-0.5); 13822 glEnd(); 13823 */ 13824 //Text::getSingleton()->drawString(Text::StrokeFont, std::string("No Translation")); 13825 13826 glTranslatef(xPosFactor*winWidth, winHeight-(yPosFactor*winHeight), 0); 13827 //float num_lines(overlay_lines.size()); 13828 13829 for (unsigned l=0; l<text_lines.size(); ++l) 13830 { 13831 glPushMatrix(); 13832 glTranslatef(0,-font_h_spacing*float(l), 0); 13833 drawString(Text::StrokeFont, text_lines[l]); 13834 glPopMatrix(); 13835 } 13836 13837 glEnable(GL_DEPTH_TEST); 13838 13839 glMatrixMode(GL_PROJECTION); 13840 glPopMatrix(); 13841 glMatrixMode( GL_MODELVIEW); 13842 glPopMatrix(); 13843 } 13844 juggler/branches/2.0/modules/vrjuggler/test/Draw/OGL/perfAddon/Text.h
r17693 r18550 36 36 Text(); 37 37 void drawString( Font, std::string ); 38 static Text *getSingleton(); 39 void *operator new( size_t size ); 38 void drawTextBlock(std::string text, const float xPosFactor=0.05f, const float yPosFactor=0.05f, 39 float fontHeight=10.0f, 40 float winHeight = 1000.0f, float winWidth = 1.4f * 1000.0f); 41 42 43 static Text *getSingleton(); 40 44 41 45 protected:
