Index: /orxonox/branches/textEngine/src/lib/graphics/font/glfont.cc
===================================================================
--- /orxonox/branches/textEngine/src/lib/graphics/font/glfont.cc	(revision 3739)
+++ /orxonox/branches/textEngine/src/lib/graphics/font/glfont.cc	(revision 3740)
@@ -437,11 +437,13 @@
    */
   int numberOfGlyphs = 90;
+
   this->initGlyphs(33, numberOfGlyphs);
+
   int rectSize = this->findOptimalFastTextureSize();
 
-  PRINTF(1)("rectSize = %d\n", rectSize);
-
-  SDL_Color tmpColor;
-  tmpColor.r = tmpColor.g = tmpColor.b = 0;
+  // setting default values. (maybe not needed afterwards)
+  //  SDL_Color tmpColor;  tmpColor.r = tmpColor.g = tmpColor.b = 0;
+  // Surface definition.
+  SDL_Rect tmpRect; // this represents a Rectangle for blitting.
   SDL_Surface* tmpSurf =  SDL_CreateRGBSurface(
 					       SDL_SWSURFACE,
@@ -460,61 +462,79 @@
 #endif
 					       );
-  SDL_Rect tmpRect;
 
   tmpRect.x = 0; tmpRect.y = 0; tmpRect.w = tmpSurf->w; tmpRect.h = tmpSurf->h;
   SDL_SetClipRect(tmpSurf, &tmpRect);
   int maxLineHeight = 0;
-  for ( int i = 33; i <= 122; i++ ) 
-    {
-      SDL_Surface* glyph = NULL;
-      SDL_Surface* glyph2 = NULL;
+
+  // all the interessting Glyphs
+  for (int i = 33; i <= 122; i++)
+    {
+      SDL_Surface* glyphSurf = NULL;
       Glyph* tmpGlyph;
 
-      tmpGlyph = this->glyphArray[i];
-      if (tmpGlyph->height > maxLineHeight)
-	maxLineHeight = tmpGlyph->height;
-
-      if (tmpRect.x+tmpGlyph->width > tmpSurf->w)
+      if (tmpGlyph = this->glyphArray[i])
 	{
-	  tmpRect.x = 0;
-	  tmpRect.y = tmpRect.y + maxLineHeight;
-	  printf("x:%d, y:%d\n", tmpRect.x, tmpRect.y);
+	  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
+	  glyphSurf = TTF_RenderGlyph_Blended(this->font,
+					      i,
+					      this->currentText->color);
+	  //					 tmpColor);
+	  if( glyphSurf ) 
+	    {
+	      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, 1);
+	      glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.maxV);
+	      glVertex2d(1, 1);
+	      glTexCoord2f(tmpTexCoord.maxU, tmpTexCoord.minV);
+	      glVertex2d(1, 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 (tmpRect.y +tmpGlyph->height > tmpSurf->h)
-	{
-	  PRINTF(1)("Protection, so font cannot write over the boundraries error\n");
-	  break;
-	}
-
-
-      glyph = TTF_RenderGlyph_Shaded(this->font,
-				     i,
-				     this->currentText->color,
-				     tmpColor);
-
-      if( glyph ) {
-	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_SetColorKey (glyph, SDL_SRCCOLORKEY, 1);
-	if (glyph->flags & SDL_SRCALPHA)
-	  printf("glyph-flags: %d\n", glyph->flags);
-
-	SDL_BlitSurface(glyph, NULL, tmpSurf, &tmpRect);
-	SDL_SaveBMP(tmpSurf, outname);
-	tmpRect.x += tmpGlyph->width+1;
-	delete tmpGlyph;
-      }
-    }
-  /*
-    tmpSurf = TTF_RenderText_Blended(this->font,
-    this->name,
-    this->currentText->color);
-  */
+    }
+
+  GLuint tmpRet = this->loadTexture(tmpSurf, NULL);
+  SDL_FreeSurface(tmpSurf);
+  return tmpRet;
 }
 
@@ -537,9 +557,11 @@
   w = powerOfTwo(surface->w);
   h = powerOfTwo(surface->h);
-  texCoord->minU = 0.0f;
-  texCoord->minV = 0.0f;
-  texCoord->maxU = (GLfloat)surface->w / w;
-  texCoord->maxV = (GLfloat)surface->h / h;
-  
+  if (texCoord)
+    {
+      texCoord->minU = 0.0f;
+      texCoord->minV = 0.0f;
+      texCoord->maxU = (GLfloat)surface->w / w;
+      texCoord->maxV = (GLfloat)surface->h / h;
+    }
   image = SDL_CreateRGBSurface(
 			       SDL_SWSURFACE,
@@ -631,4 +653,7 @@
    \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 
+   openGL-version < 1.2 compatibility. and because it is realy easy like this.
 */
 int GLFont::findOptimalFastTextureSize(void)
@@ -637,5 +662,5 @@
   int x,y; // the counters
   int maxLineHeight;
-  int size = 32; // starting Value, we have to start somewhere
+  int size = 32;      // starting Value, we have to start somewhere 32 seems reasonable.
   bool sizeOK = false;
   Glyph* tmpGlyph;
Index: /orxonox/branches/textEngine/src/lib/graphics/font/glfont.h
===================================================================
--- /orxonox/branches/textEngine/src/lib/graphics/font/glfont.h	(revision 3739)
+++ /orxonox/branches/textEngine/src/lib/graphics/font/glfont.h	(revision 3740)
@@ -56,5 +56,6 @@
   
   // OpenGL-specific
-  TexCoord texCoord;             //!< A Texture Coordinate for this glyph
+  //  TexCoord texCoord;             //!< A Texture Coordinate for this glyph.
+  GLuint displayList;            //!< DiplayList to render this Glyph.
 };
 
