Index: trunk/src/lib/graphics/importer/texture.cc
===================================================================
--- trunk/src/lib/graphics/importer/texture.cc	(revision 8316)
+++ trunk/src/lib/graphics/importer/texture.cc	(revision 8363)
@@ -37,112 +37,52 @@
  */
 Uint32 alphaMask[] = {
-	0xFF000000,
-	0x00FF0000,
-	0x0000FF00,
-	0x000000FF,
-};
+                       0xFF000000,
+                       0x00FF0000,
+                       0x0000FF00,
+                       0x000000FF,
+                     };
 
 Uint32 opaqueMask[] = {
-	0x00FF0000,
-	0x0000FF00,
-	0x000000FF,
-	0xFF000000
-};
+                        0x00FF0000,
+                        0x0000FF00,
+                        0x000000FF,
+                        0xFF000000
+                      };
 #else
 /*
- * On the LIL_ENDIAN architecture everything is fine and easy. The 24
- * and 32bit bitmaps have the same masks.
- */
+* On the LIL_ENDIAN architecture everything is fine and easy. The 24
+* and 32bit bitmaps have the same masks.
+*/
 Uint32 alphaMask[] = {
-	0x000000FF,
-	0x0000FF00,
-	0x00FF0000,
-	0xFF000000,
-};
+                       0x000000FF,
+                       0x0000FF00,
+                       0x00FF0000,
+                       0xFF000000,
+                     };
 
 Uint32 *opaqueMask = alphaMask;
-
 #endif
 
-TextureData::TextureData()
-{
-  this->bAlpha = false;
-  this->texture = 0;
-  this->image = NULL;
-}
-
-
-/**
- * @brief Destructor of a Texture
+
+
+/**
+ * @brief creates an Empty Texture,
  *
- *  Frees Data, and deletes the textures from GL
- */
-TextureData::~TextureData()
-{
-  if (this->texture != 0)
-    glDeleteTextures(1, &this->texture);
-  if (this->image != NULL)
-    SDL_FreeSurface(this->image);
-}
-
-
-/**
- * @brief Loads an SDL_Surface.
- */
-bool TextureData::loadSurface(SDL_Surface* surface, GLenum target)
-{
-  if (Texture::getTextureEnableState())
-  {
-    SDL_Surface* newSurf = Texture::prepareSurface(surface, this->bAlpha);
-    if (newSurf != NULL)
-    {
-      this->setSurface(newSurf);
-      this->setTexture(Texture::loadTexToGL(newSurf, target));
-      return true;
-    }
-  }
-  return false;
-}
-
-
-
-/**
- * @brief set the surface this Texture handles
- * @param newSurface the new Surface to set as the image for this Texture.
+ * onto this Texture you can load non-empty textures with the =
+ * operator.
+ */
+Texture::Texture()
+{
+  this->init();
+}
+
+/**
+ * @brief Creates a Texture from another Texture (copy Constructor)
+ * @param texture the Texture to copy.
  *
- * This deletes the old version of the stored Texture,
- * and sets the newly given Surface as current.
- */
-bool TextureData::setSurface(SDL_Surface* newSurface)
-{
-  if (this->image != NULL)
-    SDL_FreeSurface(this->image);
-
-  this->image = newSurface;
-
-  return (this->image != NULL);
-}
-
-
-
-bool TextureData::setTexture(GLuint texture)
-{
-     // unload the old Texture.
-  if (this->texture != 0 && glIsTexture(this->getTexture()))
-  {
-    glDeleteTextures(1, &this->texture);
-  }
-  this->texture = texture;
-  return (texture != 0);
-}
-
-Texture::Texture()
-{
-  this->init();
-}
-
-
+ * @note only the Data-Pointer will be shared.
+ */
 Texture::Texture(const Texture& texture)
-  : data(texture.data)
+    : data(texture.data)
 {
   this->setClassID(CL_TEXTURE, "Texture");
@@ -150,29 +90,24 @@
 }
 
-
+/**
+ * @brief Creates a new empty Texture with the below properties.
+ * @param target: the GL-Target.
+ * @param width: the Width of the Texture.
+ * @param height: The Hight of the Texture.
+ * @param channels: also known as BitsPerPixel.
+ * @param type the Type of Texture.
+ */
 Texture::Texture(GLenum target, unsigned int width, unsigned int height, unsigned int channels, GLenum type)
 {
   this->init();
-  GLuint texture = 0;
-  Texture::generateTexture(texture, target);
-
-  glBindTexture(target, texture);
-
-  unsigned int* pixels = new unsigned int[width * height * channels];
-  memset(pixels, 0, width * height * channels * sizeof(unsigned int));
-
-
-  glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
-  glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
-  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
-  glTexImage2D(target, 0, channels, width, height, 0, type, GL_UNSIGNED_INT, pixels);
-
-
-
-  delete[] pixels;
-
-  this->data->setTexture(texture);
+
+  SDL_Surface * surface = SDL_CreateRGBSurface(SDL_HWSURFACE, width, height, channels,
+                          alphaMask[0], alphaMask[1], alphaMask[2], alphaMask[3]);
+
+  if(surface != NULL)
+  {
+    this->data->loadSurface(surface, target);
+    SDL_FreeSurface(surface);
+  }
 }
 
@@ -218,6 +153,5 @@
  */
 Texture::~Texture()
-{
-}
+{}
 
 
@@ -308,5 +242,5 @@
   int pixelDepth = 24;
 
-	Uint32* mask = opaqueMask;
+  Uint32* mask = opaqueMask;
 
   /* Save the alpha blending attributes */
@@ -318,5 +252,5 @@
     hasAlpha = true;
     pixelDepth = 32;
-		mask = alphaMask;
+    mask = alphaMask;
   }
 
@@ -324,5 +258,5 @@
                                     surface->w, surface->h,
                                     pixelDepth,
-																		mask[0], mask[1], mask[2], mask[3] );
+                                    mask[0], mask[1], mask[2], mask[3] );
   if ( retSurface == NULL )
     return NULL;
@@ -377,11 +311,11 @@
   Texture::generateTexture(texture, target);
 
-//   glTexImage2D(target,  0,  format,
-//                surface->w,  surface->h,
-//                0, format,  GL_UNSIGNED_BYTE,
-//                surface->pixels);
-
-///  glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_REPEAT);
-///  glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_REPEAT);
+  //   glTexImage2D(target,  0,  format,
+  //                surface->w,  surface->h,
+  //                0, format,  GL_UNSIGNED_BYTE,
+  //                surface->pixels);
+
+  ///  glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_REPEAT);
+  ///  glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_REPEAT);
 
   /// TODO CHECK THIS BACK in
