core/vgui/vgui_font_textured.h
Go to the documentation of this file.
00001 // This is core/vgui/vgui_font_textured.h
00002 #ifndef vgui_font_textured_h_
00003 #define vgui_font_textured_h_
00004 //=========================================================================
00005 //:
00006 // \file
00007 // \brief  vgui_font derived class that uses textured fonts.
00008 // \author Miguel A. Figueroa-Villanueva (miguelf at ieee dot org)
00009 //
00010 // \verbatim
00011 //  Modifications
00012 //   05/27/2006 - File created. (miguelfv)
00013 // \endverbatim
00014 //=========================================================================
00015 
00016 #include <vgui/vgui_font.h>
00017 #include <vgui/vgui_gl.h>
00018 template <typename T> class vil_image_view;
00019 
00020 //-------------------------------------------------------------------------
00021 //: vgui_font derived class that uses textured fonts.
00022 //-------------------------------------------------------------------------
00023 class vgui_font_textured : public vgui_font
00024 {
00025  public:
00026 #if 0
00027   // Default constructor
00028   vgui_font_textured();
00029 #endif
00030 
00031   //: Constructor - from a font file (BMF font file only, for now).
00032   vgui_font_textured(const vcl_string& font_file);
00033 
00034   //: Draw a string of font symbols.
00035   virtual void draw(const vcl_string& str) const;
00036 
00037   //: Draw a string of font symbols.
00038   virtual void draw(const vcl_string& str, unsigned int size) const;
00039 
00040 #if 0
00041  protected:
00042 #endif
00043 
00044   //: Destructor.
00045   virtual ~vgui_font_textured();
00046 
00047  private:
00048   //: Type to store symbol location in texture.
00049   struct texture_coord
00050   {
00051     float x, y, width, height;
00052   };
00053 
00054   //: Load font from BMF file.
00055   bool load_bmf_font(const vcl_string &font_file);
00056 
00057   //: Load OpenGL texture for all symbols.
00058   void load_texture(const vil_image_view<GLubyte>& image);
00059 
00060   //: Create OpenGL display list for each symbol.
00061   void create_display_lists();
00062 
00063   //: Draw symbol using OpenGL texture map primitives.
00064   void gl_draw(unsigned int i) const;
00065 
00066   //: 256 symbol data
00067   texture_coord symbol_coords_[256];
00068 
00069   //: Base display list identifier (i.e., for the first symbol).
00070   GLuint display_list_base_id_;
00071 
00072   //: OpenGL texture identifier.
00073   GLuint texture_id_;
00074 };
00075 
00076 #endif // vgui_font_textured_h_