Index: orxonox/branches/levelloader/src/lib/graphics/importer/texture.cc
===================================================================
--- orxonox/branches/levelloader/src/lib/graphics/importer/texture.cc	(revision 3605)
+++ orxonox/branches/levelloader/src/lib/graphics/importer/texture.cc	(revision 3746)
@@ -22,98 +22,5 @@
 #include "texture.h"
 
-// headers only for PathList
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <fstream>
-
-/**
-   \brief creates a ned PathList.
-   
-   It is a good idea to use this as an initial List,
-   because if you give on a name the Path will not be checked for its existence.
-*/
-PathList::PathList()
-{
-  this->pathName = NULL;
-  this->next = NULL;
-}
-
-/**
-   \brief Creates a new PathList with a Name.
-   \param pName the Name of The Path.
-
-   This function just adds the Path without checking if it exists.
-*/
-PathList::PathList(char* pName)
-{
-  this->pathName = new char [strlen(pName)+1];
-  strcpy (this->pathName, pName);
-  this->next = NULL;
-}
-
-/**
-   \brief destroys a PathList
-
-   It does this by deleting the Name and then delete its preceding PathList.
-*/
-PathList::~PathList()
-{
-  if (this->pathName)
-    delete []this->pathName;
-  if (this->next)
-    delete this->next;
-}
-
-PathList* PathList::firstPath = NULL;
-
-/**
-   \returns A Pointer to the first Path of the Pathlist
-*/
-PathList* PathList::getInstance(void)
-{
-  if (firstPath)
-    return firstPath;
-  firstPath = new PathList();
-}
-/**
-   \brief Adds a new Pathlist Element.
-   \param pName
-   
-   Adding a Path automatically checks if the Path exists,
-   and if it does not it will not add it to the List.
-*/
-void PathList::addPath (char* pName)
-{
-  if (pName[0] == '\0')
-    {
-      PRINTF(2)("not Adding empty Path to the List.\n");
-      return;
-    }
-  char* tmpPName = new char[strlen(pName)];
-  strncpy(tmpPName, pName, strlen(pName)-1);
-  tmpPName[strlen(pName)-1] = '\0';
-  if (access (tmpPName, F_OK) == 0)
-    {
-      struct stat status;
-      stat(tmpPName, &status);
-      if (status.st_mode & S_IFDIR)
-	{
-	  PRINTF(4)("Adding Path %s to the PathList.\n", pName);
-	  PathList* tmpPathList = this;
-	  while (tmpPathList->next)
-	    tmpPathList = tmpPathList->next;
-	  tmpPathList->next = new PathList(pName);
-	}
-      else
-	PRINTF(2)("You tried to add non-folder %s to a PathList.\n", tmpPName);
-    }
-  else
-      PRINTF(2)("You tried to add non-existing folder %s to a PathList.\n", tmpPName);
-  delete []tmpPName;
-}
-
-
+#include "graphics_engine.h"
 
 /**
@@ -127,4 +34,16 @@
   this->texture = 0;
 }
+
+/**
+   \brief Constructor for a Texture
+*/
+Texture::Texture(const char* imageName)
+{
+  this->pImage = new Image;
+  this->pImage->data = NULL;
+  this->map = NULL;
+  this->texture = 0;
+  this->loadImage(imageName);
+}  
 
 /**
@@ -143,37 +62,4 @@
 
 /**
-   \brief Searches for a Texture inside one of the defined Paths
-   \param texName The name of the texture o search for.
-   \returns pathName+texName if texName was found in the pathList. NULL if the Texture is not found.
-*/
-char* Texture::searchTextureInPaths(char* texName) const
-{
-  char* tmpName = NULL;
-  PathList* pList = PathList::getInstance();
-  while (pList)
-    {
-      if (pList->pathName)
-	{
-	  tmpName = new char [strlen(pList->pathName)+strlen(texName)+1];
-	  strcpy(tmpName, pList->pathName);
-	}
-      else
-	{
-	  tmpName = new char [strlen(texName)+1];
-	  tmpName[0]='\0';
-	}
-      strcat(tmpName, texName);
-      if (access (tmpName, F_OK) == 0)
-	return tmpName;
-      
-      if (tmpName)
-	delete []tmpName;
-      tmpName = NULL;
-      pList = pList->next;
-    }
-  return NULL;
-}
-
-/**
    \brief a Simple function that switches two char values
    \param a The first value
@@ -195,61 +81,65 @@
 bool Texture::loadTexToGL (Image* pImage)
 {
-  PRINTF(4)("Loading texture to OpenGL-Environment.\n");
-  glGenTextures(1, &this->texture);
-  glBindTexture(GL_TEXTURE_2D, this->texture);
-  /* not Working, and not needed. 
-  glTexImage2D( GL_TEXTURE_2D, 0, 3, width,
-		height, 0, GL_BGR,
-		GL_UNSIGNED_BYTE, map->pixels );
-  */ 
-  gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pImage->width, pImage->height, pImage->format, GL_UNSIGNED_BYTE, pImage->data);
-  
-  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
-  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);	
-}
-
+  if (GraphicsEngine::texturesEnabled)
+    {
+      PRINTF(4)("Loading texture to OpenGL-Environment.\n");
+      glGenTextures(1, &this->texture);
+      glBindTexture(GL_TEXTURE_2D, this->texture);
+      /* not Working, and not needed. 
+	 glTexImage2D( GL_TEXTURE_2D, 0, 3, width,
+	 height, 0, GL_BGR,
+	 GL_UNSIGNED_BYTE, map->pixels );
+      */ 
+      gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pImage->width, pImage->height, pImage->format, GL_UNSIGNED_BYTE, pImage->data);
+      
+      glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
+      glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);	
+    }
+}
 
 #ifdef HAVE_SDL_SDL_IMAGE_H
-bool Texture::loadImage(char* imageName)
-{
-  char* imgNameWithPath = searchTextureInPaths(imageName);
-  if (imgNameWithPath)
-    {
-      this->map=IMG_Load(imgNameWithPath);
-      if(!map)
-	{
-	  PRINTF(1)("IMG_Load: %s\n", IMG_GetError());
+bool Texture::loadImage(const char* imageName)
+{
+  if (GraphicsEngine::texturesEnabled)
+    {
+      if (imageName)
+	{
+	  this->map=IMG_Load(imageName);
+	  if(!map)
+	    {
+	      PRINTF(1)("IMG_Load: %s\n", IMG_GetError());
+	      return false;
+	    }
+	  pImage->height = map->h;
+	  pImage->width  = map->w;
+	  pImage->data   = (GLubyte*)map->pixels;
+	  pImage->bpp    = map->format->BytesPerPixel;
+	  if (pImage->bpp == 3)
+	    pImage->format = GL_RGB;
+	  else if (pImage->bpp == 4)
+	    pImage->format = GL_RGBA;
+	  
+	  if( !IMG_isPNG(SDL_RWFromFile(imageName, "rb")) && !IMG_isJPG(SDL_RWFromFile(imageName, "rb")))
+	    for (int i=0;i<map->h * map->w *3;i+=3)
+	      { 
+		GLuint temp = pImage->data[i];
+		pImage->data[i] = pImage->data[i+2];
+		pImage->data[i+2] = temp;
+	      }
+	  /* this is the real swapping algorithm */
+	  for( int i = 0 ; i < (pImage->height / 2) ; ++i )
+	    for( int j = 0 ; j < pImage->width * pImage->bpp; j += pImage->bpp )
+	      for(int k = 0; k < pImage->bpp; ++k)
+		swap( pImage->data[ (i * pImage->width * pImage->bpp) + j + k], pImage->data[ ( (pImage->height - i - 1) * pImage->width * pImage->bpp ) + j + k]);
+	  
+	  this->loadTexToGL (this->pImage);
+	  SDL_FreeSurface(map);
+	  this->pImage->data = NULL;
+	}
+      else
+	{
+	  PRINTF(2)("Image not Found: %s\n", imageName);
 	  return false;
 	}
-      pImage->height = map->h;
-      pImage->width  = map->w;
-      pImage->data   = (GLubyte*)map->pixels;
-      pImage->bpp    = map->format->BytesPerPixel;
-      if (pImage->bpp == 3)
-	pImage->format = GL_RGB;
-      else if (pImage->bpp == 4)
-	pImage->format = GL_RGBA;
-	  
-      if( !IMG_isPNG(SDL_RWFromFile(imgNameWithPath, "rb")) && !IMG_isJPG(SDL_RWFromFile(imgNameWithPath, "rb")))
-	for (int i=0;i<map->h * map->w *3;i+=3)
-	  { 
-	    GLuint temp = pImage->data[i];
-	    pImage->data[i] = pImage->data[i+2];
-	    pImage->data[i+2] = temp;
-	  }
-      /* this is the real swapping algorithm */
-      for( int i = 0 ; i < (pImage->height / 2) ; ++i )
-	for( int j = 0 ; j < pImage->width * pImage->bpp; j += pImage->bpp )
-	  for(int k = 0; k < pImage->bpp; ++k)
-	    swap( pImage->data[ (i * pImage->width * pImage->bpp) + j + k], pImage->data[ ( (pImage->height - i - 1) * pImage->width * pImage->bpp ) + j + k]);
- 
-      this->loadTexToGL (this->pImage);
-      SDL_FreeSurface(map);
-      this->pImage->data = NULL;
-    }
-  else
-    {
-      PRINTF(2)("Image not Found: %s\n", imgNameWithPath);
-      return false;
     }
 }
@@ -262,43 +152,44 @@
    \todo Checks where to find the Image
 */
-bool Texture::loadImage(char* imageName)
-{
-  char* imgNameWithPath = searchTextureInPaths(imageName);
-  if (imgNameWithPath)
-    {
-      if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".bmp", 4))
-	{
-	  PRINTF(4)("Requested bmp-image. Trying to Import.\n");
-	  return this->loadBMP(imgNameWithPath);
-	}
-      
-      else if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".jpg", 4) || !strncmp(imgNameWithPath+strlen(imgNameWithPath)-5, ".jpg", 5))
-	{
-	  PRINTF(4)("Requested jpeg-image. Trying to Import\n");
-	  return this->loadJPG(imgNameWithPath);
-	}
-      else if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".tga", 4))
-	{
-	  PRINTF(4)("Requested tga-image. Trying to Import\n");
-	  return this->loadTGA(imgNameWithPath);
-	}
-      else if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".png", 4))
-	{
-	  PRINTF(4)("Requested png-image. Trying to Import\n");
-	  return this->loadPNG(imgNameWithPath);
+bool Texture::loadImage(const char* imageName)
+{
+  if (GraphicsEngine::texturesEnabled)
+    {
+      if (imageName)
+	{
+	  if (!strncmp(imageName+strlen(imageName)-4, ".bmp", 4))
+	    {
+	      PRINTF(4)("Requested bmp-image. Trying to Import.\n");
+	      return this->loadBMP(imageName);
+	    }
+	  
+	  else if (!strncmp(imageName+strlen(imageName)-4, ".jpg", 4) || !strncmp(imageName+strlen(imageName)-5, ".jpg", 5))
+	    {
+	      PRINTF(4)("Requested jpeg-image. Trying to Import\n");
+	      return this->loadJPG(imageName);
+	    }
+	  else if (!strncmp(imageName+strlen(imageName)-4, ".tga", 4))
+	    {
+	      PRINTF(4)("Requested tga-image. Trying to Import\n");
+	      return this->loadTGA(imageName);
+	    }
+	  else if (!strncmp(imageName+strlen(imageName)-4, ".png", 4))
+	    {
+	      PRINTF(4)("Requested png-image. Trying to Import\n");
+	      return this->loadPNG(imageName);
+	    }
+	  else
+	    {
+	      PRINTF(2)("Requested Image was not recognized in its type. (Maybe a type-Cast-error.)\n FileName: %s", imageName);
+	      return false;
+	    }
 	}
       else
 	{
-	  PRINTF(2)("Requested Image was not recognized in its type. (Maybe a type-Cast-error.)\n FileName: %s", imgNameWithPath);
+	  PRINTF(2)("Image not Found: %s\n", imageName);
 	  return false;
 	}
     }
-  else
-    {
-      PRINTF(2)("Image not Found: %s\n", imgNameWithPath);
-      return false;
-    }
-}
-
+}
 /**
    \brief reads in a Windows BMP-file, and imports it to openGL.
