Index: orxonox/trunk/src/lib/graphics/text_engine.cc
===================================================================
--- orxonox/trunk/src/lib/graphics/text_engine.cc	(revision 4537)
+++ orxonox/trunk/src/lib/graphics/text_engine.cc	(revision 4597)
@@ -1,3 +1,3 @@
-/* 
+/*
    orxonox - the future of 3D-vertical-scrollers
 
@@ -16,5 +16,5 @@
 
    !! IMPORTANT !! When using ttf fonts clear the license issues prior to
-   adding them to orxonox. This is really important, because we do not 
+   adding them to orxonox. This is really important, because we do not
    want to offend anyone.
 */
@@ -46,5 +46,5 @@
    \param type The renderType to display this font in
 
-   this constructor is private, because the user should initialize 
+   this constructor is private, because the user should initialize
    a text with the TextEngine.
 */
@@ -68,5 +68,5 @@
 /**
    \brief deletes a Text out of memory
-   
+
    This also ereases the text from the textList of the TextEngine
 */
@@ -117,11 +117,11 @@
       char* tmpText = this->text;
       while (*tmpText != '\0')
-	{
-	  if(glyphArray[*tmpText])
-	    {
-	      width += glyphArray[*tmpText]->width;
-	    }
-	  tmpText++;
-	}
+        {
+          if(glyphArray[*tmpText])
+            {
+              width += glyphArray[*tmpText]->width;
+            }
+          tmpText++;
+        }
       this->posSize.w = width;
     }
@@ -174,6 +174,6 @@
   if (likely(this->font != NULL))
     tmpSurf = TTF_RenderText_Blended(this->font->font,
-				     this->text,
-				     this->color);
+                                     this->text,
+                                     this->color);
   if (tmpSurf)
     this->texture = loadTexture(tmpSurf, &this->texCoord);
@@ -208,5 +208,5 @@
       pos.z = tmp[2];
     }
-  else 
+  else
     {
       pos.x = this->posSize.x;
@@ -232,17 +232,17 @@
       glEnable(GL_TEXTURE_2D);
       glBegin(GL_QUADS);
-      
+
       glTexCoord2f(this->texCoord.minU, this->texCoord.minV);
       glVertex2f(pos.x,   pos.y  );
-      
+
       glTexCoord2f(this->texCoord.maxU, this->texCoord.minV);
       glVertex2f(pos.x + this->posSize.w, pos.y  );
-      
+
       glTexCoord2f(this->texCoord.maxU, this->texCoord.maxV);
       glVertex2f(pos.x + this->posSize.w, pos.y + this->posSize.h);
-      
+
       glTexCoord2f(this->texCoord.minU, this->texCoord.maxV);
       glVertex2f(pos.x, pos.y + this->posSize.h);
-      
+
       glEnd();
     }
@@ -257,12 +257,12 @@
       char* tmpText = this->text;
       while (*tmpText != '\0')
-	{
-	  if(glyphArray[*tmpText])
-	    {
-	      glCallList(glyphArray[*tmpText]->displayList);
-	      glTranslatef(glyphArray[*tmpText]->width, 0, 0);
-	    }
-	  tmpText++;
-	}
+        {
+          if(glyphArray[*tmpText])
+            {
+              glCallList(glyphArray[*tmpText]->displayList);
+              glTranslatef(glyphArray[*tmpText]->width, 0, 0);
+            }
+          tmpText++;
+        }
     }
   glPopMatrix();
@@ -299,5 +299,5 @@
   Uint32 saved_flags;
   Uint8  saved_alpha;
-  
+
   /* Use the surface width and height expanded to powers of 2 */
   w = powerOfTwo(surface->w);
@@ -311,22 +311,22 @@
     }
   image = SDL_CreateRGBSurface(SDL_SWSURFACE,
-			       w, h,
-			       32,
+                               w, h,
+                               32,
 #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
-			       0x000000FF, 
-			       0x0000FF00, 
-			       0x00FF0000, 
-			       0xFF000000
+                               0x000000FF,
+                               0x0000FF00,
+                               0x00FF0000,
+                               0xFF000000
 #else
-			       0xFF000000,
-			       0x00FF0000, 
-			       0x0000FF00, 
-			       0x000000FF
+                               0xFF000000,
+                               0x00FF0000,
+                               0x0000FF00,
+                               0x000000FF
 #endif
-			       );
+                               );
   if ( image == NULL ) {
     return 0;
   }
-  
+
   /* Save the alpha blending attributes */
   saved_flags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK);
@@ -335,5 +335,5 @@
     SDL_SetAlpha(surface, 0, 0);
   }
-  
+
   /* Copy the surface into the GL texture image */
   area.x = 0;
@@ -342,10 +342,10 @@
   area.h = surface->h;
   SDL_BlitSurface(surface, &area, image, &area);
-  
+
   /* Restore the alpha blending attributes */
   if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
     SDL_SetAlpha(surface, saved_flags, saved_alpha);
   }
-  
+
   /* Create an OpenGL texture for the image */
   glGenTextures(1, &texture);
@@ -354,18 +354,18 @@
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   glTexImage2D(GL_TEXTURE_2D,
-	       0,
-	       GL_RGBA,
-	       w, h,
-	       0,
-	       GL_RGBA,
-	       GL_UNSIGNED_BYTE,
-	       image->pixels);
+               0,
+               GL_RGBA,
+               w, h,
+               0,
+               GL_RGBA,
+               GL_UNSIGNED_BYTE,
+               image->pixels);
   SDL_FreeSurface(image); /* No longer needed */
-  
+
   return texture;
 }
 
 /**
-   \brief Quick utility function for texture creation 
+   \brief Quick utility function for texture creation
    \param input an integer
    \returns the next bigger 2^n-integer than input
@@ -374,5 +374,5 @@
 {
   int value = 1;
-  
+
   while ( value < input ) {
     value <<= 1;
@@ -395,10 +395,11 @@
 Font::Font(const char* fontFile, unsigned int fontSize, Uint8 r, Uint8 g, Uint8 b)
 {
+  this->setClassID(CL_FONT, "Font");
   // setting default values.
   this->font = NULL;
   this->fontFile = NULL;
   this->glyphArray = NULL;
-  this->fastTextureID = 0;  
-  
+  this->fastTextureID = 0;
+
   this->setSize(fontSize);
 
@@ -423,5 +424,5 @@
     {
       for (int i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++)
-	delete this->glyphArray[i];
+        delete this->glyphArray[i];
       delete []this->glyphArray;
     }
@@ -441,15 +442,16 @@
   if (!this->fontFile)
     {
+      this->setName(fontFile);
       this->fontFile = new char[strlen(fontFile)+1];
       strcpy(this->fontFile, fontFile);
-      
+
       this->font = TTF_OpenFont(this->fontFile, this->fontSize);
       if(!this->font)
-	{
-	  PRINTF(1)("TTF_OpenFont: %s\n", TTF_GetError());
-	  return false;
-	}
+        {
+          PRINTF(1)("TTF_OpenFont: %s\n", TTF_GetError());
+          return false;
+        }
       else
-	  return true;
+          return true;
     }
   else
@@ -468,11 +470,11 @@
 {
   this->renderStyle = TTF_STYLE_NORMAL;
-  
+
   for (int i = 0; i < strlen(renderStyle); i++)
-    if (strncmp(renderStyle+i, "b", 1) == 0) 
+    if (strncmp(renderStyle+i, "b", 1) == 0)
       this->renderStyle |= TTF_STYLE_BOLD;
     else if (strncmp(renderStyle+i, "i", 1) == 0)
       this->renderStyle |= TTF_STYLE_ITALIC;
-    else if (strncmp(renderStyle+i, "u", 1) == 0) 
+    else if (strncmp(renderStyle+i, "u", 1) == 0)
       this->renderStyle |= TTF_STYLE_UNDERLINE;
 
@@ -547,5 +549,5 @@
    and MUST be deleted by the user..
 
-   This only works for horizontal fonts. see 
+   This only works for horizontal fonts. see
    http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
    for more info about vertical Fonts
@@ -557,7 +559,7 @@
   if (likely (this->font!= NULL))
     TTF_GlyphMetrics(this->font, rg->character,
-		     &rg->minX, &rg->maxX,
-		     &rg->minY, &rg->maxY,
-		     &rg->advance);
+                     &rg->minX, &rg->maxX,
+                     &rg->minY, &rg->maxY,
+                     &rg->advance);
   rg->height = rg->maxY - rg->minY;
   rg->width = rg->maxX - rg->minX;
@@ -569,5 +571,5 @@
 GLuint Font::createFastTexture(void)
 {
-  /* interesting GLYPHS: 
+  /* interesting GLYPHS:
    *  32: space
    *  33-47: Special Characters.
@@ -589,18 +591,18 @@
   SDL_Rect tmpRect; // this represents a Rectangle for blitting.
   SDL_Surface* tmpSurf =  SDL_CreateRGBSurface(SDL_SWSURFACE,
-					       rectSize, rectSize,
-					       32,
+                                               rectSize, rectSize,
+                                               32,
 #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
-					       0x000000FF, 
-					       0x0000FF00, 
-					       0x00FF0000, 
-					       0xFF000000
+                                               0x000000FF,
+                                               0x0000FF00,
+                                               0x00FF0000,
+                                               0xFF000000
 #else
-					       0xFF000000,
-					       0x00FF0000, 
-					       0x0000FF00, 
-					       0x000000FF
+                                               0xFF000000,
+                                               0x00FF0000,
+                                               0x0000FF00,
+                                               0x000000FF
 #endif
-					       );
+                                               );
   tmpRect.x = 0; tmpRect.y = 0; tmpRect.w = tmpSurf->w; tmpRect.h = tmpSurf->h;
   SDL_SetClipRect(tmpSurf, &tmpRect);
@@ -614,64 +616,64 @@
 
       if (tmpGlyph = this->glyphArray[i])
-	{
-	  if (tmpGlyph->height > maxLineHeight)
-	    maxLineHeight = tmpGlyph->height;
-	  
-	  if (tmpRect.x+tmpGlyph->width > tmpSurf->w)
-	    {
-	      tmpRect.x = 0;
-	      tmpRect.y = tmpRect.y + maxLineHeight + 1;
-	      maxLineHeight = 0;
-	    }
-	  if (tmpRect.y + maxLineHeight > tmpSurf->h)
-	    {
-	      PRINTF(1)("Protection, so font cannot write over the boundraries error (this should not heappen\n");
-	      break;
-	    }
-	  // reading in the new Glyph
-	  if (likely(this->font != NULL))
-	    glyphSurf = TTF_RenderGlyph_Blended(this->font, i, this->fastColor);
-	  if( glyphSurf != NULL )
-	    {
-
-	      SDL_SetAlpha(glyphSurf, 0, 0);
-
-	      SDL_BlitSurface(glyphSurf, NULL, tmpSurf, &tmpRect);
-	      TexCoord tmpTexCoord;
-	      tmpTexCoord.minU = (float)tmpRect.x/(float)tmpSurf->w;
-	      tmpTexCoord.maxU = (float)(tmpRect.x+tmpGlyph->width)/(float)tmpSurf->w;
-	      tmpTexCoord.minV = (float)tmpRect.y/(float)tmpSurf->w;
-	      tmpTexCoord.maxV = (float)(tmpRect.y+tmpGlyph->height)/(float)tmpSurf->w;
-	      tmpGlyph->displayList = glGenLists(1);
-
-	      glNewList(tmpGlyph->displayList, GL_COMPILE);
-	      glBegin(GL_QUADS);
-	      glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.minV);
-	      glVertex2d(0, 0);
-	      glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.maxV);
-	      glVertex2d(0, tmpGlyph->height);
-	      glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.maxV);
-	      glVertex2d(tmpGlyph->width, tmpGlyph->height);
-	      glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.minV);
-	      glVertex2d(tmpGlyph->width, 0);
-	      glEnd();
-	      glEndList();
-	      SDL_FreeSurface(glyphSurf);
-
-	      tmpRect.x += tmpGlyph->width + 1;
-
-	      // Outputting Glyphs to BMP-files.
-	      /*
-		char outname[64];
-		if (i < 10)
-		sprintf( outname, "glyph-00%d.bmp", i );
-		else if (i <100)
-		sprintf( outname, "glyph-0%d.bmp", i );
-		else
-		sprintf( outname, "glyph-%d.bmp", i );
-		SDL_SaveBMP(tmpSurf, outname);
-	      */
-	    }
-	}
+        {
+          if (tmpGlyph->height > maxLineHeight)
+            maxLineHeight = tmpGlyph->height;
+
+          if (tmpRect.x+tmpGlyph->width > tmpSurf->w)
+            {
+              tmpRect.x = 0;
+              tmpRect.y = tmpRect.y + maxLineHeight + 1;
+              maxLineHeight = 0;
+            }
+          if (tmpRect.y + maxLineHeight > tmpSurf->h)
+            {
+              PRINTF(1)("Protection, so font cannot write over the boundraries error (this should not heappen\n");
+              break;
+            }
+          // reading in the new Glyph
+          if (likely(this->font != NULL))
+            glyphSurf = TTF_RenderGlyph_Blended(this->font, i, this->fastColor);
+          if( glyphSurf != NULL )
+            {
+
+              SDL_SetAlpha(glyphSurf, 0, 0);
+
+              SDL_BlitSurface(glyphSurf, NULL, tmpSurf, &tmpRect);
+              TexCoord tmpTexCoord;
+              tmpTexCoord.minU = (float)tmpRect.x/(float)tmpSurf->w;
+              tmpTexCoord.maxU = (float)(tmpRect.x+tmpGlyph->width)/(float)tmpSurf->w;
+              tmpTexCoord.minV = (float)tmpRect.y/(float)tmpSurf->w;
+              tmpTexCoord.maxV = (float)(tmpRect.y+tmpGlyph->height)/(float)tmpSurf->w;
+              tmpGlyph->displayList = glGenLists(1);
+
+              glNewList(tmpGlyph->displayList, GL_COMPILE);
+              glBegin(GL_QUADS);
+              glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.minV);
+              glVertex2d(0, 0);
+              glTexCoord2f(tmpTexCoord.minU, tmpTexCoord.maxV);
+              glVertex2d(0, tmpGlyph->height);
+              glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.maxV);
+              glVertex2d(tmpGlyph->width, tmpGlyph->height);
+              glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.minV);
+              glVertex2d(tmpGlyph->width, 0);
+              glEnd();
+              glEndList();
+              SDL_FreeSurface(glyphSurf);
+
+              tmpRect.x += tmpGlyph->width + 1;
+
+              // Outputting Glyphs to BMP-files.
+              /*
+                char outname[64];
+                if (i < 10)
+                sprintf( outname, "glyph-00%d.bmp", i );
+                else if (i <100)
+                sprintf( outname, "glyph-0%d.bmp", i );
+                else
+                sprintf( outname, "glyph-%d.bmp", i );
+                SDL_SaveBMP(tmpSurf, outname);
+              */
+            }
+        }
     }
 
@@ -682,11 +684,11 @@
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   glTexImage2D(GL_TEXTURE_2D,
-	       0,
-	       GL_RGBA,
-	       tmpSurf->w, tmpSurf->h,
-	       0,
-	       GL_RGBA,
-	       GL_UNSIGNED_BYTE,
-	       tmpSurf->pixels);
+               0,
+               GL_RGBA,
+               tmpSurf->w, tmpSurf->h,
+               0,
+               GL_RGBA,
+               GL_UNSIGNED_BYTE,
+               tmpSurf->pixels);
   SDL_FreeSurface(tmpSurf);
   return texture;
@@ -707,9 +709,9 @@
       this->glyphArray = new Glyph*[FONT_HIGHEST_KNOWN_CHAR];
       for (int i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++)
-	this->glyphArray[i] = NULL;
-    }
-  
+        this->glyphArray[i] = NULL;
+    }
+
   Uint16 lastGlyph = from + count;
-  
+
   for (int i = from; i <= lastGlyph; i++)
     {
@@ -723,8 +725,8 @@
    \returns the optimal size to use as the texture size
 
-   \todo: this algorithm can be a lot more faster, althought it does 
+   \todo: this algorithm can be a lot more faster, althought it does
    not really matter within the init-context, and 128 glyphs.
 
-   This function searches for a 2^n sizes texture-size, this is for 
+   This function searches for a 2^n sizes texture-size, this is for
    openGL-version < 1.2 compatibility ( and because it is realy easy like this :))
 */
@@ -743,27 +745,27 @@
       maxLineHeight = 0;
       for (i = 0; i < FONT_HIGHEST_KNOWN_CHAR; i++)
-	{
-	  if(tmpGlyph = this->glyphArray[i])
-	    {
-	      // getting the height of the highest Glyph in the Line.
-	      if (tmpGlyph->height > maxLineHeight)
-		maxLineHeight = tmpGlyph->height;
-
-	      if (x + tmpGlyph->width > size)
-		{
-		  x = 0;
-		  y = y + maxLineHeight;
-		  maxLineHeight = 0;
-		}
-	      if (y + maxLineHeight + 1 > size)
-		break;
-	      x += tmpGlyph->width + 1;
-
-	    }
-	}
+        {
+          if(tmpGlyph = this->glyphArray[i])
+            {
+              // getting the height of the highest Glyph in the Line.
+              if (tmpGlyph->height > maxLineHeight)
+                maxLineHeight = tmpGlyph->height;
+
+              if (x + tmpGlyph->width > size)
+                {
+                  x = 0;
+                  y = y + maxLineHeight;
+                  maxLineHeight = 0;
+                }
+              if (y + maxLineHeight + 1 > size)
+                break;
+              x += tmpGlyph->width + 1;
+
+            }
+        }
       if (i == FONT_HIGHEST_KNOWN_CHAR)
-	sizeOK = true;
+        sizeOK = true;
       else
-	size *= 2;
+        size *= 2;
     }
   return size;
@@ -801,7 +803,8 @@
    \brief standard constructor
 */
-TextEngine::TextEngine () 
+TextEngine::TextEngine ()
 {
    this->setClassID(CL_TEXT_ENGINE, "TextEngine");
+   this->setName("TextEngine");
    this->enableFonts();
 
@@ -818,8 +821,8 @@
 
 */
-TextEngine::~TextEngine () 
+TextEngine::~TextEngine ()
 {
   this->disableFonts();
-  
+
   delete this->textList;
 
@@ -835,5 +838,5 @@
     {
       if(TTF_Init()==-1)
-	PRINTF(1)("TTF_Init: %s\n", TTF_GetError());
+        PRINTF(1)("TTF_Init: %s\n", TTF_GetError());
 
       TextEngine::checkVersion();
@@ -932,5 +935,5 @@
 /**
    \brief outputs some nice Debug information
-   
+
    \todo there should also be something outputted about Font
 */
@@ -941,5 +944,5 @@
   PRINT(0)("+-------------------------------+\n");
   PRINT(0)("Reference: %p; Text Counts: %d\n", this, this->textList->getSize());
-  
+
   tIterator<Text>* textIterator = textList->getIterator();
   Text* text = textIterator->nextElement();
@@ -973,13 +976,13 @@
   else
     {
-      PRINTF(2)("compiled with SDL_ttf version: %d.%d.%d\n", 
-		compile_version.major,
-		compile_version.minor,
-		compile_version.patch);
-      
-      PRINTF(2)("running with SDL_ttf version: %d.%d.%d\n", 
-		link_version.major,
-		link_version.minor,
-		link_version.patch);
+      PRINTF(2)("compiled with SDL_ttf version: %d.%d.%d\n",
+                compile_version.major,
+                compile_version.minor,
+                compile_version.patch);
+
+      PRINTF(2)("running with SDL_ttf version: %d.%d.%d\n",
+                link_version.major,
+                link_version.minor,
+                link_version.patch);
       return false;
     }
