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

Overlay Class Reference

#include <overlay.h>

Collaboration diagram for Overlay:

Collaboration graph
List of all members.

Public Member Functions

void begin ()
void beginText ()
void end ()
void endText ()
 Overlay ()
void print (char *)
void print (char)
void print (wchar_t)
void printf (const char *,...)
void rect (float x, float y, float w, float h, bool fill=true)
void setFont (TextureFont *)
void setWindowSize (int, int)
 ~Overlay ()

Private Attributes

TextureFontfont
bool fontChanged
OverlayStreamBuf sbuf
int textBlock
bool useTexture
int windowHeight
int windowWidth

Constructor & Destructor Documentation

Overlay::Overlay  ) 
 

Definition at line 20 of file overlay.cpp.

References sbuf, and OverlayStreamBuf::setOverlay().

00020                  :
00021     ostream(&sbuf),
00022     windowWidth(1),
00023     windowHeight(1),
00024     font(NULL),
00025     useTexture(false),
00026     fontChanged(false),
00027     textBlock(0)
00028 {
00029     sbuf.setOverlay(this);
00030 }

Overlay::~Overlay  ) 
 

Definition at line 32 of file overlay.cpp.

00033 {
00034 }


Member Function Documentation

void Overlay::begin  ) 
 

Definition at line 37 of file overlay.cpp.

References useTexture, windowHeight, and windowWidth.

Referenced by CelestiaCore::renderOverlay().

00038 {
00039     glMatrixMode(GL_PROJECTION);
00040     glPushMatrix();
00041     glLoadIdentity();
00042     gluOrtho2D(0, windowWidth, 0, windowHeight);
00043     glMatrixMode(GL_MODELVIEW);
00044     glPushMatrix();
00045     glLoadIdentity();
00046     glTranslatef(0.125f, 0.125f, 0);
00047 
00048     glDisable(GL_LIGHTING);
00049     glDisable(GL_TEXTURE_2D);
00050     glEnable(GL_BLEND);
00051     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00052 
00053     useTexture = false;
00054 }

void Overlay::beginText  ) 
 

Definition at line 81 of file overlay.cpp.

References textBlock.

Referenced by CelestiaCore::renderOverlay().

00082 {
00083     glPushMatrix();
00084     textBlock++;
00085 }

void Overlay::end  ) 
 

Definition at line 56 of file overlay.cpp.

Referenced by CelestiaCore::renderOverlay().

00057 {
00058     glMatrixMode(GL_PROJECTION);
00059     glPopMatrix();
00060     glMatrixMode(GL_MODELVIEW);
00061     glPopMatrix();
00062 }

void Overlay::endText  ) 
 

Definition at line 87 of file overlay.cpp.

References textBlock.

Referenced by CelestiaCore::renderOverlay().

00088 {
00089     if (textBlock > 0)
00090     {
00091         textBlock--;
00092         glPopMatrix();
00093     }
00094 }

void Overlay::print char *   ) 
 

Definition at line 156 of file overlay.cpp.

References print(), UTF8Decode(), and UTF8EncodedSize().

00157 {
00158 #if 0
00159     while (*s != '\0')
00160         print(*s++);
00161 #else
00162     int length = strlen(s);
00163     bool validChar = true;
00164         int i = 0;
00165     while (i < length && validChar)
00166     {
00167         wchar_t ch = 0;
00168         validChar = UTF8Decode(s, i, length, ch);
00169         i += UTF8EncodedSize(ch);
00170         print(ch);
00171     }
00172 #endif    
00173 }

void Overlay::print char   ) 
 

Definition at line 127 of file overlay.cpp.

References TextureFont::bind(), font, fontChanged, TextureFont::getHeight(), TextureFont::render(), textBlock, and useTexture.

00128 {
00129     if (font != NULL)
00130     {
00131         if (!useTexture || fontChanged)
00132         {
00133             glEnable(GL_TEXTURE_2D);
00134             font->bind();
00135             useTexture = true;
00136             fontChanged = false;
00137         }
00138 
00139         switch (c)
00140         {
00141         case '\n':
00142             if (textBlock > 0)
00143             {
00144                 glPopMatrix();
00145                 glTranslatef(0, -(1 + font->getHeight()), 0);
00146                 glPushMatrix();
00147             }
00148             break;
00149         default:
00150             font->render(c);
00151             break;
00152         }
00153     }
00154 }

void Overlay::print wchar_t   ) 
 

Definition at line 97 of file overlay.cpp.

References TextureFont::bind(), font, fontChanged, TextureFont::getHeight(), TextureFont::render(), textBlock, and useTexture.

Referenced by OverlayStreamBuf::overflow(), print(), and printf().

00098 {
00099     if (font != NULL)
00100     {
00101         if (!useTexture || fontChanged)
00102         {
00103             glEnable(GL_TEXTURE_2D);
00104             font->bind();
00105             useTexture = true;
00106             fontChanged = false;
00107         }
00108 
00109         switch (c)
00110         {
00111         case '\n':
00112             if (textBlock > 0)
00113             {
00114                 glPopMatrix();
00115                 glTranslatef(0, -(1 + font->getHeight()), 0);
00116                 glPushMatrix();
00117             }
00118             break;
00119         default:
00120             font->render(c);
00121             break;
00122         }
00123     }
00124 }

void Overlay::printf const char *  ,
  ...
 

Definition at line 176 of file overlay.cpp.

References print().

Referenced by CelestiaCore::renderOverlay().

00177 {
00178     va_list args;
00179     va_start(args, format);
00180 
00181     char buf[1024];
00182     vsprintf(buf, format, args);
00183     print(buf);
00184     
00185     va_end(args);
00186 }

void Overlay::rect float  x,
float  y,
float  w,
float  h,
bool  fill = true
 

Definition at line 189 of file overlay.cpp.

References useTexture.

Referenced by CelestiaCore::renderOverlay().

00190 {
00191     if (useTexture)
00192     {
00193         glDisable(GL_TEXTURE_2D);
00194         useTexture = false;
00195     }
00196 
00197     if (fill)
00198     {
00199         glRectf(x, y, x + w, y + h);
00200     }
00201     else
00202     {
00203         glBegin(GL_LINE_LOOP);
00204         glVertex3f(x, y, 0);
00205         glVertex3f(x + w, y, 0);
00206         glVertex3f(x + w, y + h, 0);
00207         glVertex3f(x, y + h, 0);
00208         glEnd();
00209     }
00210 }

void Overlay::setFont TextureFont  ) 
 

Definition at line 71 of file overlay.cpp.

References font, and fontChanged.

Referenced by CelestiaCore::renderOverlay().

00072 {
00073     if (f != font)
00074     {
00075         font = f;
00076         fontChanged = true;
00077     }
00078 }

void Overlay::setWindowSize int  ,
int 
 

Definition at line 65 of file overlay.cpp.

References windowHeight, and windowWidth.

Referenced by CelestiaCore::initRenderer(), and CelestiaCore::resize().

00066 {
00067     windowWidth = w;
00068     windowHeight = h;
00069 }


Member Data Documentation

TextureFont* Overlay::font [private]
 

Definition at line 72 of file overlay.h.

Referenced by print(), and setFont().

bool Overlay::fontChanged [private]
 

Definition at line 74 of file overlay.h.

Referenced by print(), and setFont().

OverlayStreamBuf Overlay::sbuf [private]
 

Definition at line 77 of file overlay.h.

Referenced by Overlay().

int Overlay::textBlock [private]
 

Definition at line 75 of file overlay.h.

Referenced by beginText(), endText(), and print().

bool Overlay::useTexture [private]
 

Definition at line 73 of file overlay.h.

Referenced by begin(), print(), and rect().

int Overlay::windowHeight [private]
 

Definition at line 71 of file overlay.h.

Referenced by begin(), and setWindowSize().

int Overlay::windowWidth [private]
 

Definition at line 70 of file overlay.h.

Referenced by begin(), and setWindowSize().


The documentation for this class was generated from the following files:
Generated on Sat Jan 14 22:33:30 2006 for Celestia by  doxygen 1.4.1