Main Page   Namespace List   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

/cygdrive/d/Eigene Dateien/!DProcs/code_gen/DrawText.h

Go to the documentation of this file.
00001 //
00002 // This CTextDrawer singleton class written by Martin G Bell, 2003.
00003 //
00004 // * Based on NeHe lesson 17 with adaptations by Marco Monster.
00005 // * Original NeHe comments:
00006 // *        This Code Was Created By Jeff Molofee 2000
00007 // *        And Modified By Giuseppe D'Agata (waveform@tiscalinet.it)
00008 // *        If You've Found This Code Useful, Please Let Me Know.
00009 // *        Visit My Site At nehe.gamedev.net
00010 //
00011 // Description:
00012 //
00013 //   Text drawing class that uses the singleton design pattern.
00014 //
00015 // Usage:
00016 //
00017 //   init: TEXTDRAWER.SetFontTextureId(aFontTextureId); // See note below.
00018 //   then: TEXTDRAWER.SetColor(R, G, B, A);             // Defaults to opaque white.
00019 //       TEXTDRAWER.PrintText(x, y, aString, ...);
00020 //
00021 //   Note: Requires a 256x256 texture containing 16x16 font glyphs.
00022 //
00023 
00024 #ifndef _DRAWTEXT_H
00025 #define _DRAWTEXT_H
00026 
00027 //#include <windows.h>
00028 #include <GL/gl.h>
00029 
00030 
00031 // The number of chars in our font texture.
00032 // We are assuming two sets of 128 chars (e.g. as created by Bitmap Font Creator).
00033 #define NUMCHARS    256
00034 
00035 
00036 #define TEXTDRAWER CTextDrawer::GetSingleton()
00037 #define DESTROY_TEXTDRAWER CTextDrawer::Destroy()
00038 
00039 
00040 // Util function prototypes.
00041 void Go2d();
00042 void Exit2d();
00043 
00044 
00045 //
00046 // Singleton class to draw text as texture-mapped polygons.
00047 //
00048 class CTextDrawer
00049 {
00050 
00051 public:     // Interface
00052 
00053     static CTextDrawer& GetSingleton();
00054     static void Destroy();
00055 
00056     bool PrintText(bool bold, int maxLength, const char *aFmt, ...);
00057     void SetFontTextureId(GLuint aFontTextureId);
00058     void SetColor(float aR, float aG, float aB, float aA);
00059 
00060 private:    // Implementation
00061 
00062     CTextDrawer();
00063     static void Initialise();                           
00064 
00065 private:    // Data
00066 
00067     static CTextDrawer* mSingleton;
00068 
00069     GLuint mBaseListId;     // Start list id
00070     unsigned int mFontTexId;        // GL font texture id.
00071     float mR, mG, mB, mA;   // Colour.
00072 };
00073 
00074 
00075 #endif

Generated on Thu Mar 18 18:33:47 2004 for miniQT by doxygen1.2.18