Index: trunk/src/lib/graphics/importer/multi_frame_texture.cc
===================================================================
--- trunk/src/lib/graphics/importer/texture.cc	(revision 5856)
+++ trunk/src/lib/graphics/importer/multi_frame_texture.cc	(revision 5858)
@@ -16,8 +16,10 @@
 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_IMPORTER
 
-#include "texture.h"
+#include "multi_frame_texture.h"
 
 #include "debug.h"
 #include "graphics_engine.h"
+
+#include <stdarg.h>
 
 #ifdef HAVE_SDL_IMAGE_H
@@ -30,208 +32,34 @@
  *  Constructor for a Texture
 */
-Texture::Texture(const char* imageName)
+MultiFrameTexture::MultiFrameTexture(unsigned int count, ...)
 {
   this->setClassID(CL_TEXTURE, "Texture");
-
-  this->bAlpha = false;
-  this->texture = 0;
-  this->image = NULL;
-
-  if (imageName != NULL)
-  {
-    this->setName(imageName);
-    this->loadImage(imageName);
-  }
-}
-
-/**
- *  Destructor of a Texture
-
-   Frees Data, and deletes the textures from GL
-*/
-Texture::~Texture()
-{
-  if (this->texture != 0)
-    glDeleteTextures(1, &this->texture);
-  if (this->image != NULL)
-    SDL_FreeSurface(this->image);
-}
-
-
-/**
- *  loads an Image from a file to a Texture
- * @param imageName The image to load
-*/
-bool Texture::loadImage(const char* imageName)
-{
-  if (GraphicsEngine::texturesEnabled)
-    {
-      if (this->image != NULL)
-        {
-          SDL_FreeSurface(this->image);
-          this->image = NULL;
-        }
-      if (this->texture != 0)
-        {
-          glDeleteTextures(1, &this->texture);
-          this->texture = 0;
-        }
-      if (imageName != NULL)
-        {
-          SDL_Surface* tmpSurf;
-          if (this->texture != 0 && glIsTexture(this->texture))
-            glDeleteTextures(1, &this->texture);
-          // load the new Image to memory
-          tmpSurf = IMG_Load(imageName);
-          if(tmpSurf != NULL)
-          {
-            PRINTF(4)("loading Image %s\n", imageName);
-            if (this->prepareSurface(tmpSurf))
-              this->texture = Texture::loadTexToGL(this->image);
-
-            SDL_FreeSurface(tmpSurf);
-            return true;
-          }
-          else
-            {
-              PRINTF(1)("IMG_Load: %s\n", IMG_GetError());
-              this->texture = 0;
-              return false;
-            }
-        }
-      else
-        {
-          PRINTF(2)("Image-Name not specified\n");
-          return false;
-        }
-    }
-  return false;
-}
-
-bool Texture::rebuild()
-{
-  if (this->texture != 0 && glIsTexture(this->texture))
-    {
-      glDeleteTextures(1,&this->texture);
-      this->texture = 0;
-    }
-
-  if (this->image != NULL)
-    {
-      PRINTF(3)("Reloading Texture of %s '%s'\n", this->getClassName(), this->getName());
-      this->texture = loadTexToGL(this->image);
-    }
 
 }
 
 /**
- * converts surface to a new SDL_Surface, that is loadable by openGL
- * @param surface the Surface to convert
- * @returns a !!new!! Surface, that is loadable by openGL.
- */
-bool Texture::prepareSurface(SDL_Surface* surface)
+ *  Destructor of a MultiFrameTexture
+
+   Frees Data, and deletes the textures from GL
+*/
+MultiFrameTexture::~MultiFrameTexture()
 {
-  PRINTF(4)("Loading texture to OpenGL-Environment.\n");
-
-  SDL_Surface* putSurface;
-  SDL_Rect area;
-  Uint32 saved_flags;
-  Uint8  saved_alpha;
-
-  putSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,
-                               surface->w, surface->h,
-                               32,
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
-                               0x000000FF,
-                               0x0000FF00,
-                               0x00FF0000,
-                               0xFF000000
-#else
-                               0xFF000000,
-                               0x00FF0000,
-                               0x0000FF00,
-                               0x000000FF
-#endif
-                               );
-  if ( putSurface == NULL )
-  {
-    this->setSurface(NULL);
-    return false;
-  }
-
-  /* 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, putSurface, &area);
-
-  /* Restore the alpha blending attributes */
-  if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA )
-  {
-    SDL_SetAlpha(surface, saved_flags | SDL_OPENGL, saved_alpha);
-    this->bAlpha = true;
-  }
-
-  return (this->setSurface(putSurface));
-}
-
-bool Texture::setSurface(SDL_Surface* newSurface)
-{
-  if (this->image != NULL)
-    SDL_FreeSurface(this->image);
-
-  this->image = newSurface;
-
-  return (this->image != NULL);
 }
 
 
-/**
- *  Loads a Texture to the openGL-environment.
- * @param surface the Image to load to openGL
- * @returns The ID of the texture.
- */
-GLuint Texture::loadTexToGL (const SDL_Surface* surface)
+
+bool MultiFrameTexture::rebuild()
 {
-//   if (this->texture != 0 && glIsTexture(this->texture))
-//     glDeleteTextures(1, &this->texture);
-//   this->texture = 0;
+//   if (this->texture != 0 && glIsMultiFrameTexture(this->texture))
+//     {
+//       glDeleteMultiFrameTextures(1,&this->texture);
+//       this->texture = 0;
+//     }
+//
+//   if (this->image != NULL)
+//     {
+//       PRINTF(3)("Reloading MultiFrameTexture of %s '%s'\n", this->getClassName(), this->getName());
+//       this->texture = loadTexToGL(this->image);
+//     }
 
-  GLuint texture;
-
-  if (surface == NULL)
-    return 0;
-
-  /* Create an OpenGL texture for the image */
-  glGenTextures(1, &texture);
-  glBindTexture(GL_TEXTURE_2D, texture);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-  // build the Texture
-  glTexImage2D(GL_TEXTURE_2D,
-               0,
-               GL_RGBA,
-               surface->w, surface->h,
-               0,
-               GL_RGBA,
-               GL_UNSIGNED_BYTE,
-               surface->pixels);
-  // build the MipMaps
-  gluBuild2DMipmaps(GL_TEXTURE_2D,
-                    GL_RGBA,
-                    surface->w,
-                    surface->h,
-                    GL_RGBA,
-                    GL_UNSIGNED_BYTE,
-                    surface->pixels);
-  glBindTexture(GL_TEXTURE_2D, 0);
-  return texture;
 }
