Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

StatusBar.H

Go to the documentation of this file.
00001 
00010 #ifndef STATUSBAR_H
00011 #define STATUSBAR_H
00012 
00013 #define OUTSIDE_GLUE_CORE
00014 #include <std/strings.H>
00015 #include <config/config.H>
00016 
00017 #include "DrawObj.H"
00018 #include "Color.H"
00019 #include "FPS.H"
00020 #include "FontMgr.H"
00021 
00022 namespace InSpace {
00023 
00024 class StatusBar : public DrawObj
00025 {
00026  public:
00027   StatusBar(cXYpt screenLoc, const bool showFPS, 
00028         const Color col=Color(1,1,0), const int font=0,
00029         float fontScaleFactor=0.025) :
00030     DrawObj("StatusBar") {
00031     _loc = screenLoc;
00032     _showfps = showFPS;
00033     _col = col;
00034     _font = font;
00035     _scale = fontScaleFactor;
00036     
00037     DRAWMGR::register2DObj(this);
00038   }
00039 
00040   virtual ~StatusBar() {}
00041 
00042   void setMessage(str_ptr s) { _msg = s; }
00043   void clearMessage() { _msg = str_ptr::null_str(); }
00044 
00045   void draw() {
00046     glMatrixMode(GL_PROJECTION);
00047     glPushMatrix();
00048     glLoadIdentity();
00049     
00050     glMatrixMode(GL_MODELVIEW);
00051     glPushMatrix();
00052     glLoadIdentity();
00053     
00054     str_ptr fpsstr;
00055 
00056     if (_showfps) {
00057       char s[64];
00058       sprintf(s, "%3.1f fps", (float)FPS::fps());
00059       fpsstr = str_ptr(s);
00060     }
00061 
00062     // project onto the screen
00063     Wvec posonscreen = Wvec(_loc[0],_loc[1],0.0);
00064     Wtransf m = Wtransf::translation(posonscreen) * Wtransf::scaling(_scale);
00065     glMultMatrixd(m.matrix());
00066 
00067     glDisable(GL_LIGHTING);
00068     glDisable(GL_COLOR_MATERIAL);
00069     glDisable(GL_TEXTURE_2D);
00070     glColor4fv(_col.array());
00071 
00072     str_ptr text = fpsstr + str_ptr(" ") + _msg;
00073     FONTMGR::render(**text, 0,0,0, _font);
00074     
00075     glMatrixMode(GL_MODELVIEW);
00076     glPopMatrix();  // pop modelview
00077     glMatrixMode(GL_PROJECTION);
00078     glPopMatrix();  // pop projection
00079   }
00080 
00081  protected: 
00082   str_ptr _msg;
00083   XYpt    _loc;
00084   bool    _showfps;
00085   Color   _col;
00086   int     _font;
00087   float   _scale;
00088 };
00089 
00090 }
00091 #endif

Generated on Thu Jul 8 15:19:29 2004 for inspace by doxygen 1.3.4