Index: orxonox/trunk/src/sfont/font.cc
===================================================================
--- orxonox/trunk/src/sfont/font.cc	(revision 3477)
+++ orxonox/trunk/src/sfont/font.cc	(revision 3477)
@@ -0,0 +1,59 @@
+/*
+Copyright (C) 2004 Lion Vollnhals
+Copyright (C) 2003 Matthias Braun
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+#ifndef __LIB_2D_FONT_HPP__
+#define __LIB_2D_FONT_HPP__
+
+#include <string>
+#include <stdexcept>
+#include "SFont.h"
+
+/** A thin c++ wrapper around my custom SFont version */
+class SFont
+{
+public:
+	int getHeight() const
+	{ return SFont_TextHeight(font); }
+
+	int getTextWidth(const char* text) const
+	{ return SFont_TextWidth(font, text); }
+	int getTextWidth(const std::string& text) const
+	{ return getTextWidth(text.c_str()); }
+
+	void write(SDL_Surface* surface, const char* text, int x, int y) const
+	{ SFont_Write(surface, font, x, y, text); }
+	
+	void write(SDL_Surface* surface, const std::string& text, int x, int y) const
+	{ Write(surface, text.c_str(), x, y); }
+
+	Font(SDL_Surface* surface)
+	{
+		font = SFont_InitFont(surface);
+		if(!font)
+			throw std::runtime_error("Couldn't initialize font.");
+	}
+	~Font()
+	{ SFont_FreeFont(font); }
+	
+private:
+	SFont_Font* font;
+};
+
+#endif
+
+
Index: orxonox/trunk/src/sfont/fontset.cc
===================================================================
--- orxonox/trunk/src/sfont/fontset.cc	(revision 3477)
+++ orxonox/trunk/src/sfont/fontset.cc	(revision 3477)
@@ -0,0 +1,226 @@
+/* 
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Benjamin Grauer
+   co-programmer: ...
+
+   ***
+   * This file is extended to the needs of the orxonox-project.         *
+   * The main difference to the version of Marius is, that textures get *
+   * loaded by orxonox Texture-class, and that the comments are set up, *
+   * in doxygen style                                                   *
+   * the Copyright of the original file is below this copyright, and we *
+   * hope not to offend Marius through this.                            *
+                                                                      ***
+
+*/
+
+/***************************************************************************
+                          cone3dfont.cpp  -  description
+                             -------------------
+    copyright            : (C) 2001 by Marius Andra aka Cone3D
+    email                : marius@hot.ee
+    ICQ                  : 43999510
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+
+#include "fontset.h"
+#include <stdarg.h>
+
+#include "../importer/texture.h"
+
+/** 
+    \brief initializes a new fontset
+*/
+FontSet::FontSet()
+{
+  this->sizex=1.0f;
+  this->sizey=1.0f;
+  this->font = NULL;
+}
+
+/** 
+    \brief initializes a new fontset with a texture for the font
+    \param fontFile The fontfile to load
+*/
+FontSet::FontSet(char* fontFile)
+{
+  this->sizex=1.0f;
+  this->sizey=1.0f;
+  this->font = NULL;
+  
+}
+
+/**
+   \brief deletes the Fontset by freeing all allocated space
+   and then deleting the Texture.
+*/
+FontSet::~FontSet()
+{
+  killFont();
+  // delete the texture;
+  delete font;
+}
+
+/**
+   \brief sets the size of the font
+   \param x the width of the font
+   \param y the height of the font
+*/
+int FontSet::setSize(float x, float y)
+{
+  sizex=x;
+  sizey=y;
+  
+  return 1;
+}
+
+/**
+   \brief builds the fontset
+   \param file the name of the file to get the fontset from.
+*/
+int FontSet::buildFont(char *file)
+{
+  int loop1;
+  float cx, cy;
+  
+  if (!font)
+    delete font;
+  font = new Texture();
+  font->loadImage(file);
+  
+  base=glGenLists(256);                          // Creating 256 Display Lists
+  glBindTexture(GL_TEXTURE_2D, font->getTexture()); // Select Our Font Texture
+  for (loop1=0; loop1<256; loop1++)              // Loop Through All 256 Lists
+    {
+      cx=(float)(loop1%16)/16.0f;                  // X Position Of Current Character
+      cy=(float)(loop1/16)/16.0f;                  // Y Position Of Current Character
+      
+      glNewList(base+loop1,GL_COMPILE);            // Start Building A List
+      glBegin(GL_QUADS);                           // Use A Quad For Each Character
+      glTexCoord2f(cx,1.0f-cy-0.0625f);          // Texture Coord (Bottom Left)
+      glVertex2d(0,16);                          // Vertex Coord (Bottom Left)
+      glTexCoord2f(cx+0.0625f,1.0f-cy-0.0625f);  // Texture Coord (Bottom Right)
+      glVertex2i(16,16);                         // Vertex Coord (Bottom Right)
+      glTexCoord2f(cx+0.0625f,1.0f-cy-0.001f);   // Texture Coord (Top Right)
+      glVertex2i(16,0);                          // Vertex Coord (Top Right)
+      glTexCoord2f(cx,1.0f-cy-0.001f);           // Texture Coord (Top Left)
+      glVertex2i(0,0);                           // Vertex Coord (Top Left)
+      glEnd();                                     // Done Building Our Quad (Character)
+      glTranslated(12,0,0);                        // Move To The Right Of The Character
+      glEndList();                                 // Done Building The Display List
+    }                                              // Loop Until All 256 Are Built
+  return 1;
+}
+
+/**
+   \brief deletes the display lists.
+*/
+int FontSet::killFont(void)                          // Delete The Font From Memory
+{
+  glDeleteLists(base,256);                       // Delete All 256 Display Lists
+  return 1;
+}
+
+/**
+   \brief prints out some text
+   \param x most left coordinate of the text.
+   \param y the top coordinate of the text
+   \param type Type of text
+   \param fmt The text to display
+   \param ... more text
+*/
+int FontSet::printText(int x, int y, char type, char *fmt,...)// Where The Printing Happens
+{
+  char    text[1024];                            // Holds Our String
+  int blendOn,scissorOn,textureOn,lightOn;  // Holds the previous GL settings
+  int depthOn,matrixMode,screenStats[4],blendSrc,blendDst;
+  char typ=type;
+
+  va_list ap;                                    // Pointer To List Of Arguments
+
+  if (fmt == NULL)                               // If There's No Text
+    return 1;                                      // Do Nothing
+  
+  va_start(ap, fmt);                             // Parses The String For Variables
+  vsprintf(text, fmt, ap);                       // And Converts Symbols To Actual Numbers
+  va_end(ap);                                    // Results Are Stored In Text
+  
+  if (type>3)                                     // Did User Choose An Invalid Character Set?
+    type=3;                                       // If So, Select Set 2 (Italic)
+  
+  textureOn = glIsEnabled(GL_TEXTURE_2D); // Were textures enabled?
+  depthOn = glIsEnabled(GL_DEPTH_TEST);  // Was GL_DEPTH_TEST enabled?
+  lightOn = glIsEnabled(GL_LIGHTING); // Was GL_LIGHTING enabled?
+  scissorOn = glIsEnabled(GL_SCISSOR_TEST);  // etc.
+  glGetIntegerv(GL_MATRIX_MODE, &matrixMode);
+  glGetIntegerv(GL_VIEWPORT, screenStats);
+  blendOn= glIsEnabled(GL_BLEND);
+  glGetIntegerv(GL_BLEND_SRC, &blendSrc);
+  glGetIntegerv(GL_BLEND_DST, &blendDst);
+  
+  if (depthOn) glDisable(GL_DEPTH_TEST);  // If they were enabled/disabled
+  if (!textureOn) glEnable(GL_TEXTURE_2D); // then enable/disable them
+  if (!blendOn) glEnable(GL_BLEND);
+  if (!scissorOn) glEnable(GL_SCISSOR_TEST);
+  if (lightOn) glDisable(GL_LIGHTING);
+  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Set the correct blending mode
+  
+  glMatrixMode(GL_PROJECTION); // and initalize Ortho mode
+  glPushMatrix();
+  glLoadIdentity();
+  glOrtho(0.0f,screenStats[2],screenStats[3],0.0f,-1.0f,1.0f);
+  glMatrixMode(GL_MODELVIEW);
+  glPushMatrix();
+  glBindTexture(GL_TEXTURE_2D, font->getTexture());
+
+  if(type>1) typ=typ-2;
+  glLoadIdentity();
+  glTranslated(x,y,0);
+  glListBase(base-32+(128*typ));
+  glScalef(sizex,sizey,1.0f);
+  glCallLists(strlen(text),GL_UNSIGNED_BYTE, text); // Write The Text To The Screen
+  
+  if(type>1)
+    {
+      glLoadIdentity();
+      glTranslated(x+1,y,0);
+      glListBase(base-32+(128*(type-2)));
+      glScalef(sizex,sizey,1.0f);
+      glCallLists(strlen(text),GL_UNSIGNED_BYTE, text); // Write The Text To The Screen
+    }
+
+  glBindTexture(GL_TEXTURE_2D, 0); // Fix everything up
+  glMatrixMode(GL_PROJECTION);
+  glPopMatrix();
+  glMatrixMode(GL_MODELVIEW);
+  glPopMatrix();
+
+  if (depthOn) glEnable(GL_DEPTH_TEST);
+  if (!textureOn) glDisable(GL_TEXTURE_2D);
+  if (!blendOn) glDisable(GL_BLEND);
+  if (!scissorOn) glDisable(GL_SCISSOR_TEST);
+  if (lightOn) glEnable(GL_LIGHTING);
+
+  glBlendFunc(blendSrc, blendDst);
+  glMatrixMode(matrixMode);
+
+  return 1;
+}
Index: orxonox/trunk/src/sfont/fontset.h
===================================================================
--- orxonox/trunk/src/sfont/fontset.h	(revision 3477)
+++ orxonox/trunk/src/sfont/fontset.h	(revision 3477)
@@ -0,0 +1,52 @@
+/*! 
+    \file fontset.h
+    \brief Handles the display of Text.
+*/
+
+/**
+  This file is extended to the needs of the orxonox-project.
+  The main difference to the version of Marius is, that textures get 
+  loaded by orxonox Texture-class
+*/
+
+#ifndef _FONTSET_H
+#define _FONTSET_H
+
+class Texture;
+
+//! A class to handle a FontSet.
+/**
+   A fontset is an entire Alphabet (256 entries) of one font.
+   It is made by creating a file containing a matrix with 256
+   little pictures in it, displaying the letters of this alphabet.
+   Then these letters are projected onto Quads, which can be aranged
+   in a sorted order, to display some text
+
+   usage:
+   1. initialize the Class by loading the source-font-picture
+   2. set the size
+   3. write some text with printText
+   4. delete the class again.
+*/ 
+class FontSet
+{
+ public:
+  FontSet();
+  FontSet(char *file);
+  ~FontSet();
+  
+  int buildFont(char* fontFile);
+  int printText(int x, int y, char type, char *fmt, ...);
+  int killFont(void);
+  int setSize(float x, float y);
+  
+ private:
+  int base;          //!< Save the glLists here.
+  float sizex;       //!< the width of the text.
+  float sizey;       //!< the height of the text.
+  Texture* font;     //!< texture of the font.
+
+};
+
+
+#endif /* _FONTSET_H */
Index: orxonox/trunk/src/sfont/glfont.cc
===================================================================
--- orxonox/trunk/src/sfont/glfont.cc	(revision 3477)
+++ orxonox/trunk/src/sfont/glfont.cc	(revision 3477)
@@ -0,0 +1,545 @@
+/* 
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Benjamin Grauer
+   co-programmer: ...
+
+   ***
+   * This file is extended to the needs of the orxonox-project.         *
+   * the Copyright of the original file is below this copyright         *
+   *                                                                  ***
+
+*/
+
+/*
+    glfont:  An example of using the SDL_ttf library with OpenGL.
+    Copyright (C) 1997-2004 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    The SDL_GL_* functions in this file are available in the public domain.
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+
+#include "glfont.h"
+
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <SDL/SDL.h>
+#include <SDL/SDL_ttf.h>
+
+#include "../glincl.h"
+#include "../debug.h"
+
+
+#define DEFAULT_PTSIZE	18
+#define DEFAULT_TEXT	"orxonox 1234567890"
+#define NUM_COLORS      256
+
+
+
+GLFont::GLFont()
+{
+  this->init("");
+
+}
+GLFont::GLFont(const char* fontFile)
+{
+  this->init(fontFile);
+}
+GLFont::~GLFont()
+{
+  
+}
+
+bool GLFont::init(const char* fontFile)
+{
+  // setting default values.
+  renderStyle = TTF_STYLE_NORMAL;
+
+
+  // Initializing lib-TTF if necesary.
+  if (TTF_WasInit() && TTF_Init() < 0 ) 
+    {
+      PRINTF(1)("Couldn't initialize TTF: %s\n", SDL_GetError());
+      return false;
+    }
+}
+
+bool GLFont::ttfInitialized = false;
+
+bool GLFont::setFont(const char* fonFile)
+{
+
+}
+void GLFont::setText(const char* text)
+{
+
+}
+
+void GLFont::setStyle(char* style)
+{
+  renderStyle = TTF_STYLE_NORMAL;
+  
+  for (int i = 0; i < strlen(style); i++)
+    if (strncmp(style+i, "b", 1) == 0) 
+      this->renderStyle |= TTF_STYLE_BOLD;
+    else if (strncmp(style+i, "i", 1) == 0)
+      this->renderStyle |= TTF_STYLE_ITALIC;
+    else if (strncmp(style+i, "u", 1) == 0) 
+      this->renderStyle |= TTF_STYLE_UNDERLINE;
+
+  // TTF_SetFontStyle(font, renderstyle);
+
+}
+void GLFont::setSize(void)
+{
+
+}
+void GLFont::setPosition(int x, int y)
+{
+
+}
+
+void GLFont::renderText(void)
+{
+
+}
+void GLFont::renderText(const char* text, int x, int y)
+{
+  // enter the 2D-Mode
+
+  SDL_Surface *screen = SDL_GetVideoSurface();
+  
+  /* Note, there may be other things you need to change,
+     depending on how you have your OpenGL state set up.
+  */
+  glPushAttrib(GL_ENABLE_BIT);
+  glDisable(GL_DEPTH_TEST);
+  glDisable(GL_CULL_FACE);
+  glEnable(GL_TEXTURE_2D);
+  
+  /* This allows alpha blending of 2D textures with the scene */
+  glEnable(GL_BLEND);
+  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+  
+  glViewport(0, 0, screen->w, screen->h);
+  
+  glMatrixMode(GL_PROJECTION);
+  glPushMatrix();
+  glLoadIdentity();
+  
+  glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0);
+  
+  glMatrixMode(GL_MODELVIEW);
+  glPushMatrix();
+  glLoadIdentity();
+  
+  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+
+
+
+
+  // Leave the 2D-Mode
+  glMatrixMode(GL_MODELVIEW);
+  glPopMatrix();
+  
+  glMatrixMode(GL_PROJECTION);
+  glPopMatrix();
+  
+  glPopAttrib();
+}
+
+
+bool GLFont::loadTexture()
+{
+  int w, h;
+  SDL_Surface *image;
+  SDL_Rect area;
+  Uint32 saved_flags;
+  Uint8  saved_alpha;
+  
+  /* Use the surface width and height expanded to powers of 2 */
+  w = powerOfTwo(surface->w);
+  h = powerOfTwo(surface->h);
+  texcoord[0] = 0.0f;			/* Min X */
+  texcoord[1] = 0.0f;			/* Min Y */
+  texcoord[2] = (GLfloat)surface->w / w;	/* Max X */
+  texcoord[3] = (GLfloat)surface->h / h;	/* Max Y */
+  
+  image = SDL_CreateRGBSurface(
+			       SDL_SWSURFACE,
+			       w, h,
+			       32,
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
+			       0x000000FF, 
+			       0x0000FF00, 
+			       0x00FF0000, 
+			       0xFF000000
+#else
+			       0xFF000000,
+			       0x00FF0000, 
+			       0x0000FF00, 
+			       0x000000FF
+#endif
+			       );
+  if ( image == NULL ) {
+    return 0;
+  }
+  
+  /* Save the alpha blending attributes */
+  saved_flags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK);
+  saved_alpha = surface->format->alpha;
+  if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
+    SDL_SetAlpha(surface, 0, 0);
+  }
+  
+  /* Copy the surface into the GL texture image */
+  area.x = 0;
+  area.y = 0;
+  area.w = surface->w;
+  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);
+  glBindTexture(GL_TEXTURE_2D, texture);
+  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+  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);
+  SDL_FreeSurface(image); /* No longer needed */
+  
+  //  return texture;
+}
+
+/* Quick utility function for texture creation */
+int GLFont::powerOfTwo(int input)
+{
+  int value = 1;
+  
+  while ( value < input ) {
+    value <<= 1;
+  }
+  return value;
+}
+
+
+/*
+private:
+char* fontFile;
+char* text;
+int positionX;
+int positionY;
+*/
+
+
+
+
+char Usage[100] = "orxonox test" ;
+void SDL_GL_Enter2DMode()
+{
+}
+
+void SDL_GL_Leave2DMode()
+{
+}
+
+/* Quick utility function for texture creation */
+static int power_of_two(int input)
+{
+}
+
+
+
+GLuint SDL_GL_LoadTexture(SDL_Surface *surface, GLfloat *texcoord)
+{
+
+}
+
+int setup(int argc, char *argv[])
+{
+	char *argv0 = argv[0];
+	SDL_Surface *screen;
+	TTF_Font *font;
+	SDL_Surface *text;
+	int ptsize;
+	int i, done;
+	SDL_Color white = { 0xFF, 0xFF, 0xFF, 0 };
+	SDL_Color black = { 0x00, 0x00, 0x00, 0 };
+	SDL_Color *forecol;
+	SDL_Color *backcol;
+	GLenum gl_error;
+	GLuint texture;
+	int x, y, w, h;
+	GLfloat texcoord[4];
+	GLfloat texMinX, texMinY;
+	GLfloat texMaxX, texMaxY;
+
+	int renderstyle;
+	int dump;
+	enum {
+		RENDER_LATIN1,
+		RENDER_UTF8,
+		RENDER_UNICODE
+	} rendertype;
+	char *message;
+
+	/* Look for special execution mode */
+	dump = 0;
+	/* Look for special rendering types */
+	rendertype = RENDER_LATIN1;
+	/* Default is black and white */
+	forecol = &black;
+	backcol = &white;
+	for ( i=1; argv[i] && argv[i][0] == '-'; ++i ) {
+		if ( strcmp(argv[i], "-utf8") == 0 ) {
+			rendertype = RENDER_UTF8;
+		} else
+		if ( strcmp(argv[i], "-unicode") == 0 ) {
+			rendertype = RENDER_UNICODE;
+		} else
+		if ( strcmp(argv[i], "-b") == 0 ) {
+			renderstyle |= TTF_STYLE_BOLD;
+		} else
+		if ( strcmp(argv[i], "-i") == 0 ) {
+			renderstyle |= TTF_STYLE_ITALIC;
+		} else
+		if ( strcmp(argv[i], "-u") == 0 ) {
+			renderstyle |= TTF_STYLE_UNDERLINE;
+		} else
+		if ( strcmp(argv[i], "-dump") == 0 ) {
+			dump = 1;
+		} else
+		if ( strcmp(argv[i], "-fgcol") == 0 ) {
+			int r, g, b;
+			if ( sscanf (argv[++i], "%d,%d,%d", &r, &g, &b) != 3 ) {
+				fprintf(stderr, Usage, argv0);
+				return(1);
+			}
+			forecol->r = (Uint8)r;
+			forecol->g = (Uint8)g;
+			forecol->b = (Uint8)b;
+		} else
+		if ( strcmp(argv[i], "-bgcol") == 0 ) {
+			int r, g, b;
+			if ( sscanf (argv[++i], "%d,%d,%d", &r, &g, &b) != 3 ) {
+				fprintf(stderr, Usage, argv0);
+				return(1);
+			}
+			backcol->r = (Uint8)r;
+			backcol->g = (Uint8)g;
+			backcol->b = (Uint8)b;
+		} else {
+			fprintf(stderr, Usage, argv0);
+			return(1);
+		}
+	}
+	argv += i;
+	argc -= i;
+
+	/* Check usage */
+	if ( ! argv[0] ) {
+		fprintf(stderr, Usage, argv0);
+		return(1);
+	}
+
+	/* Initialize SDL */
+	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+		return(2);
+	}
+	atexit(SDL_Quit);
+
+	/* Initialize the TTF library */
+	if ( TTF_Init() < 0 ) {
+		fprintf(stderr, "Couldn't initialize TTF: %s\n",SDL_GetError());
+		return(2);
+	}
+	atexit(TTF_Quit);
+
+	/* Open the font file with the requested point size */
+	ptsize = 0;
+	if ( argc > 1 ) {
+		ptsize = atoi(argv[1]);
+	}
+	if ( ptsize == 0 ) {
+		i = 2;
+		ptsize = DEFAULT_PTSIZE;
+	} else {
+		i = 3;
+	}
+	font = TTF_OpenFont(argv[0], ptsize);
+	if ( font == NULL ) {
+		fprintf(stderr, "Couldn't load %d pt font from %s: %s\n",
+					ptsize, argv[0], SDL_GetError());
+		return(2);
+	}
+
+	if( dump ) {
+
+		for( i = 48; i < 123; i++ ) {
+			SDL_Surface* glyph = NULL;
+
+			glyph = TTF_RenderGlyph_Shaded( font, i, *forecol, *backcol );
+
+			if( glyph ) {
+				char outname[64];
+				sprintf( outname, "glyph-%d.bmp", i );
+				SDL_SaveBMP( glyph, outname );
+			}
+
+		}
+
+		return( 0 );
+	}
+
+	/* Set a 640x480 video mode */
+	screen = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
+	if ( screen == NULL ) {
+		fprintf(stderr, "Couldn't set 640x480 OpenGL mode: %s\n",
+							SDL_GetError());
+		return(2);
+	}
+
+	/* Render and center the message */
+	if ( argc > 2 ) {
+		message = argv[2];
+	} else {
+		message = DEFAULT_TEXT;
+	}
+	switch (rendertype) {
+	    case RENDER_LATIN1:
+		text = TTF_RenderText_Blended(font, message, *forecol);
+		break;
+
+	    case RENDER_UTF8:
+		text = TTF_RenderUTF8_Blended(font, message, *forecol);
+		break;
+
+	    case RENDER_UNICODE:
+		{
+			/* This doesn't actually work because you can't pass
+			   UNICODE text in via command line, AFAIK, but...
+			 */
+			Uint16 unicode_text[BUFSIZ];
+			int index;
+			for ( index = 0; (message[0] || message[1]); ++index ) {
+				unicode_text[index]  = ((Uint8 *)message)[0];
+				unicode_text[index] <<= 8;
+				unicode_text[index] |= ((Uint8 *)message)[1];
+				message += 2;
+			}
+			text = TTF_RenderUNICODE_Blended(font,
+					unicode_text, *forecol);
+		}
+		break;
+	    default:
+		text = NULL; /* This shouldn't happen */
+		break;
+	}
+	if ( text == NULL ) {
+		fprintf(stderr, "Couldn't render text: %s\n", SDL_GetError());
+		TTF_CloseFont(font);
+		return(2);
+	}
+	x = (screen->w - text->w)/2;
+	y = (screen->h - text->h)/2;
+	w = text->w;
+	h = text->h;
+	printf("Font is generally %d big, and string is %hd big\n",
+						TTF_FontHeight(font), text->h);
+
+	/* Convert the text into an OpenGL texture */
+	glGetError();
+	texture = SDL_GL_LoadTexture(text, texcoord);
+	if ( (gl_error = glGetError()) != GL_NO_ERROR ) {
+		/* If this failed, the text may exceed texture size limits */
+		printf("Warning: Couldn't create texture: 0x%x\n", gl_error);
+	}
+
+	/* Make texture coordinates easy to understand */
+	texMinX = texcoord[0];
+	texMinY = texcoord[1];
+	texMaxX = texcoord[2];
+	texMaxY = texcoord[3];
+
+	/* We don't need the original text surface anymore */
+	SDL_FreeSurface(text);
+
+	/* Initialize the GL state */
+	glViewport( 0, 0, screen->w, screen->h );
+	glMatrixMode( GL_PROJECTION );
+	glLoadIdentity( );
+
+	glOrtho( -2.0, 2.0, -2.0, 2.0, -20.0, 20.0 );
+
+	glMatrixMode( GL_MODELVIEW );
+	glLoadIdentity( );
+
+	glEnable(GL_DEPTH_TEST);
+
+	glDepthFunc(GL_LESS);
+
+	glShadeModel(GL_SMOOTH);
+
+	/* Wait for a keystroke, and blit text on mouse press */
+	done = 0;
+	while ( ! done ) {
+
+	  /* Show the text on the screen */
+	  SDL_GL_Enter2DMode();
+	  glBindTexture(GL_TEXTURE_2D, texture);
+	  glBegin(GL_QUADS);
+	  glTexCoord2f(texMinX, texMinY); glVertex2i(x,   y  );
+	  glTexCoord2f(texMaxX, texMinY); glVertex2i(x+w, y  );
+	  glTexCoord2f(texMinX, texMaxY); glVertex2i(x,   y+h);
+	  glTexCoord2f(texMaxX, texMaxY); glVertex2i(x+w, y+h);
+	  glEnd();
+	  SDL_GL_Leave2DMode();
+	  
+	  /* Swap the buffers so everything is visible */
+	  SDL_GL_SwapBuffers( );
+	}
+	TTF_CloseFont(font);
+	return(0);
+}
+
Index: orxonox/trunk/src/sfont/glfont.h
===================================================================
--- orxonox/trunk/src/sfont/glfont.h	(revision 3477)
+++ orxonox/trunk/src/sfont/glfont.h	(revision 3477)
@@ -0,0 +1,48 @@
+/*! 
+    \file glfont.h
+    \brief Handles the display of glFonts.
+*/
+
+#ifndef _GLFONT_H
+#define _GLFONT_H
+
+#include "../glincl.h"
+
+class GLFont
+{
+ public:
+  GLFont();
+  GLFont(const char* fontFile);
+  ~GLFont();
+  
+
+
+  bool setFont(const char* fontFile);
+  void setText(const char* text);
+
+  void setStyle(char* style);
+  void setSize(void);
+  void setPosition(int x, int y);
+  
+  void renderText(void);
+  void renderText(const char* text, int x, int y);
+
+ private:
+  char* fontFile;
+  char* text;
+  GLuint texture;
+  int positionX;
+  int positionY;
+  int renderStyle;
+  SDL_Surface* surface;
+  GLfloat* texcoord;
+
+  bool init(const char* fontFile);
+  bool loadTexture();
+  static int powerOfTwo(int input);
+
+  static bool ttfInitialized;
+
+};
+
+#endif /* _GLFONT_H */
Index: orxonox/trunk/src/sfont/sfont.c
===================================================================
--- orxonox/trunk/src/sfont/sfont.c	(revision 3477)
+++ orxonox/trunk/src/sfont/sfont.c	(revision 3477)
@@ -0,0 +1,178 @@
+/*  SFont: a simple font-library that uses special .pngs as fonts
+    Copyright (C) 2003 Karl Bartel
+
+    License: GPL or LGPL (at your choice)
+    WWW: http://www.linux-games.com/sfont/
+
+    This program is free software; you can redistribute it and/or modify        
+    it under the terms of the GNU General Public License as published by        
+    the Free Software Foundation; either version 2 of the License, or           
+    (at your option) any later version.                                         
+                                                                                
+    This program is distributed in the hope that it will be useful,       
+    but WITHOUT ANY WARRANTY; without even the implied warranty of              
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               
+    GNU General Public License for more details.                
+                                                                               
+    You should have received a copy of the GNU General Public License           
+    along with this program; if not, write to the Free Software                 
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   
+                                                                                
+    Karl Bartel
+    Cecilienstr. 14                                                    
+    12307 Berlin
+    GERMANY
+    karlb@gmx.net                                                      
+*/                                                                            
+#include <SDL.h>
+
+#include <assert.h>
+#include <stdlib.h>
+#include "SFont.h"
+
+static Uint32 GetPixel(SDL_Surface *Surface, Sint32 X, Sint32 Y)
+{
+   Uint8  *bits;
+   Uint32 Bpp;
+
+   assert(X>=0);
+   assert(X<Surface->w);
+   
+   Bpp = Surface->format->BytesPerPixel;
+   bits = ((Uint8 *)Surface->pixels)+Y*Surface->pitch+X*Bpp;
+
+   // Get the pixel
+   switch(Bpp) {
+      case 1:
+         return *((Uint8 *)Surface->pixels + Y * Surface->pitch + X);
+         break;
+      case 2:
+         return *((Uint16 *)Surface->pixels + Y * Surface->pitch/2 + X);
+         break;
+      case 3: { // Format/endian independent 
+         Uint8 r, g, b;
+         r = *((bits)+Surface->format->Rshift/8);
+         g = *((bits)+Surface->format->Gshift/8);
+         b = *((bits)+Surface->format->Bshift/8);
+         return SDL_MapRGB(Surface->format, r, g, b);
+         }
+         break;
+      case 4:
+         return *((Uint32 *)Surface->pixels + Y * Surface->pitch/4 + X);
+         break;
+   }
+
+   return -1;
+}
+
+SFont_Font* SFont_InitFont(SDL_Surface* Surface)
+{
+    int x = 0, i = 0;
+    Uint32 pixel;
+    SFont_Font* Font;
+    Uint32 pink;
+
+    if (Surface == NULL)
+	return NULL;
+
+    Font = (SFont_Font *) malloc(sizeof(SFont_Font));
+    Font->Surface = Surface;
+
+    SDL_LockSurface(Surface);
+
+    pink = SDL_MapRGB(Surface->format, 255, 0, 255);
+    while (x < Surface->w) {
+	if (GetPixel(Surface, x, 0) == pink) { 
+    	    Font->CharPos[i++]=x;
+    	    while((x < Surface->w) && (GetPixel(Surface, x, 0)== pink))
+		x++;
+	    Font->CharPos[i++]=x;
+	}
+	x++;
+    }
+    Font->MaxPos = x-1;
+    
+    pixel = GetPixel(Surface, 0, Surface->h-1);
+    SDL_UnlockSurface(Surface);
+    SDL_SetColorKey(Surface, SDL_SRCCOLORKEY, pixel);
+
+    return Font;
+}
+
+void SFont_FreeFont(SFont_Font* FontInfo)
+{
+    SDL_FreeSurface(FontInfo->Surface);
+    free(FontInfo);
+}
+
+void SFont_Write(SDL_Surface *Surface, const SFont_Font *Font,
+		 int x, int y, const char *text)
+{
+    const char* c;
+    int charoffset;
+    SDL_Rect srcrect, dstrect;
+
+    if(text == NULL)
+	return;
+
+    // these values won't change in the loop
+    srcrect.y = 1;
+    dstrect.y = y;
+    srcrect.h = dstrect.h = Font->Surface->h - 1;
+
+    for(c = text; *c != '\0' && x <= Surface->w ; c++) {
+	charoffset = ((int) (*c - 33)) * 2 + 1;
+	// skip spaces and nonprintable characters
+	if (*c == ' ' || charoffset < 0 || charoffset > Font->MaxPos) {
+	    x += Font->CharPos[2]-Font->CharPos[1];
+	    continue;
+	}
+
+	srcrect.w = dstrect.w = 
+	    (Font->CharPos[charoffset+2] + Font->CharPos[charoffset+1])/2 -
+	    (Font->CharPos[charoffset] + Font->CharPos[charoffset-1])/2;
+	srcrect.x = (Font->CharPos[charoffset]+Font->CharPos[charoffset-1])/2;
+	dstrect.x = x - (float)(Font->CharPos[charoffset]
+			      - Font->CharPos[charoffset-1])/2;
+
+	SDL_BlitSurface(Font->Surface, &srcrect, Surface, &dstrect); 
+
+	x += Font->CharPos[charoffset+1] - Font->CharPos[charoffset];
+    }
+}
+
+int SFont_TextWidth(const SFont_Font *Font, const char *text)
+{
+    const char* c;
+    int charoffset=0;
+    int width = 0;
+
+    if(text == NULL)
+	return 0;
+
+    for(c = text; *c != '\0'; c++) {
+	charoffset = ((int) *c - 33) * 2 + 1;
+	// skip spaces and nonprintable characters
+        if (*c == ' ' || charoffset < 0 || charoffset > Font->MaxPos) {
+            width += Font->CharPos[2]-Font->CharPos[1];
+	    continue;
+	}
+	
+	width += Font->CharPos[charoffset+1] - Font->CharPos[charoffset];
+    }
+
+    return width;
+}
+
+int SFont_TextHeight(const SFont_Font* Font)
+{
+    return Font->Surface->h - 1;
+}
+
+void SFont_WriteCenter(SDL_Surface *Surface, const SFont_Font *Font,
+		       int y, const char *text)
+{
+    SFont_Write(Surface, Font, Surface->w/2 - SFont_TextWidth(Font, text)/2,
+	    	y, text);
+}
+
Index: orxonox/trunk/src/sfont/sfont.h
===================================================================
--- orxonox/trunk/src/sfont/sfont.h	(revision 3477)
+++ orxonox/trunk/src/sfont/sfont.h	(revision 3477)
@@ -0,0 +1,83 @@
+/*  SFont: a simple font-library that uses special bitmaps as fonts
+    Copyright (C) 2003 Karl Bartel
+
+    License: GPL or LGPL (at your choice)
+    WWW: http://www.linux-games.com/sfont/
+
+    This program is free software; you can redistribute it and/or modify        
+    it under the terms of the GNU General Public License as published by        
+    the Free Software Foundation; either version 2 of the License, or           
+    (at your option) any later version.                                         
+                                                                                
+    This program is distributed in the hope that it will be useful,       
+    but WITHOUT ANY WARRANTY; without even the implied warranty of              
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               
+    GNU General Public License for more details.                
+                                                                               
+    You should have received a copy of the GNU General Public License           
+    along with this program; if not, write to the Free Software                 
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   
+                                                                                
+    Karl Bartel
+    Cecilienstr. 14                                                    
+    12307 Berlin
+    GERMANY
+    karlb@gmx.net                                                      
+*/                                                                            
+
+/************************************************************************ 
+*    SFONT - SDL Font Library by Karl Bartel <karlb@gmx.net>            *
+*                                                                       *
+*  All functions are explained below. For further information, take a   *
+*  look at the example files, the links at the SFont web site, or       *
+*  contact me, if you problem isn' addressed anywhere.                  *
+*                                                                       *
+************************************************************************/
+#ifndef SFONT_H
+#define SFONT_H
+
+#include <SDL.h>
+
+#ifdef __cplusplus 
+extern "C" {
+#endif
+
+// Delcare one variable of this type for each font you are using.
+// To load the fonts, load the font image into YourFont->Surface
+// and call InitFont( YourFont );
+typedef struct {
+	SDL_Surface *Surface;	
+	int CharPos[512];
+	int MaxPos;
+} SFont_Font;
+
+// Initializes the font
+// Font: this contains the suface with the font.
+//       The Surface must be loaded before calling this function
+SFont_Font* SFont_InitFont (SDL_Surface *Font);
+
+// Frees the font
+// Font: The font to free
+//       The font must be loaded before using this function.
+void SFont_FreeFont(SFont_Font* Font);
+
+// Blits a string to a surface
+// Destination: the suface you want to blit to
+// text: a string containing the text you want to blit.
+void SFont_Write(SDL_Surface *Surface, const SFont_Font *Font, int x, int y,
+				 const char *text);
+
+// Returns the width of "text" in pixels
+int SFont_TextWidth(const SFont_Font* Font, const char *text);
+// Returns the height of "text" in pixels (which is always equal to Font->Surface->h)
+int SFont_TextHeight(const SFont_Font* Font);
+
+// Blits a string to Surface with centered x position
+void SFont_WriteCenter(SDL_Surface *Surface, const SFont_Font* Font, int y,
+					   const char *text);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SFONT_H */
