Index: /branches/avi_play/src/lib/graphics/importer/media_container.cc
===================================================================
--- /branches/avi_play/src/lib/graphics/importer/media_container.cc	(revision 6316)
+++ /branches/avi_play/src/lib/graphics/importer/media_container.cc	(revision 6317)
@@ -50,10 +50,12 @@
 MediaContainer::~MediaContainer()
 {
-  // delete all surfaces in the list
-  while(!this->surface_list.empty())
+  // delete all textures.
+  while(!this->texture_list.empty())
   {
-    SDL_FreeSurface(this->surface_list.back());
-    this->surface_list.pop_back();
+    if (glIsTexture(this->texture_list.back()))
+      glDeleteTextures(1, &this->texture_list.back());
+    this->texture_list.pop_back();
   }
+  glDeleteTextures(1, &texture);
   SDL_FreeSurface(surface);
 
@@ -82,7 +84,8 @@
 
   fps = 0;
-}
-
-SDL_Surface* MediaContainer::getFrame(int frame_number)
+  frame_num = 0;
+}
+
+GLuint MediaContainer::getFrame(int frame_number)
 {
   // seek doesnt work for the first two frames
@@ -112,5 +115,5 @@
 }
 
-SDL_Surface* MediaContainer::getNextFrame()
+GLuint MediaContainer::getNextFrame()
 {
   /* get next frame */
@@ -127,7 +130,11 @@
                            packet.data, packet.size);
 
+      // Free the packet that was allocated by av_read_frame
+      av_free_packet(&packet);
+      
       // Did we get a video frame?
       if(frame_finished)
       {
+        frame_num++;
         //PRINTF(1)("frame_number: %i\n", this->getFrameNumber());
         // Conversion from YUV to RGB
@@ -163,9 +170,37 @@
                                             );
 
-        return surface;
+        // NOTE: use glTexSubImage2D, it's faster!! //
+        /* Create an OpenGL texture from the surface */
+        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_RGB,
+                    surface->w, surface->h,
+                    0,
+                    GL_RGB,
+                    GL_UNSIGNED_BYTE,
+                    surface->pixels);
+        // build the MipMaps
+        gluBuild2DMipmaps(GL_TEXTURE_2D,
+                          GL_RGB,
+                          surface->w,
+                          surface->h,
+                          GL_RGB,
+                          GL_UNSIGNED_BYTE,
+                          surface->pixels);
+        glBindTexture(GL_TEXTURE_2D, 0);
+
+        return texture;
       }
     }
-    // Free the packet that was allocated by av_read_frame
-    av_free_packet(&packet);
+    else
+    {
+      av_free_packet(&packet);
+      this->getNextFrame();
+    }
   }
   else
@@ -173,11 +208,11 @@
 }
 
-vector<SDL_Surface*> MediaContainer::getFrameList()
-{
-
-  while((surface = this->getNextFrame()) != NULL)
-    surface_list.push_back(surface);
-
-  return surface_list;
+vector<GLuint> MediaContainer::getFrameList()
+{
+
+  while((texture = this->getNextFrame()) != NULL)
+    texture_list.push_back(texture);
+
+  return texture_list;
 }
 
@@ -189,5 +224,5 @@
 
   // Open file
-  sprintf(filename, "frame%i.ppm", codec_context->frame_number);
+  sprintf(filename, "frame%i.ppm", frame_num);
   file = fopen(filename, "wb");
   if(file == NULL)
@@ -264,4 +299,6 @@
   // duration
   duration = format_context->duration / 1000000LL;
+
+  frame_num = 0;
 }
 
@@ -278,5 +315,5 @@
 int MediaContainer::getFrameNumber()
 {
-  return codec_context->frame_number;
+  return frame_num;
 }
 
Index: /branches/avi_play/src/lib/graphics/importer/media_container.h
===================================================================
--- /branches/avi_play/src/lib/graphics/importer/media_container.h	(revision 6316)
+++ /branches/avi_play/src/lib/graphics/importer/media_container.h	(revision 6317)
@@ -20,4 +20,6 @@
 #include "base_object.h"
 
+#include "glincl.h"
+
 /* using namespace std is default, this needs to be here */
 using namespace std;
@@ -30,4 +32,5 @@
   double fps;
   SDL_Surface* surface;
+  GLuint texture;
   uint8_t* data;
 
@@ -44,6 +47,7 @@
   int video_stream;
   int duration;
+  int frame_num;
 
-  vector<SDL_Surface*>    surface_list;
+  vector<GLuint>    texture_list;
 
 public:
@@ -54,7 +58,7 @@
 
   void init();
-  SDL_Surface* getFrame(int frame_number);
-  SDL_Surface* getNextFrame();
-  vector<SDL_Surface*> getFrameList();
+  GLuint getFrame(int frame_number);
+  GLuint getNextFrame();
+  vector<GLuint> getFrameList();
   void loadMedia(const char* filename);
 
Index: /branches/avi_play/src/lib/graphics/importer/movie_player.cc
===================================================================
--- /branches/avi_play/src/lib/graphics/importer/movie_player.cc	(revision 6316)
+++ /branches/avi_play/src/lib/graphics/importer/movie_player.cc	(revision 6317)
@@ -58,5 +58,5 @@
   status = STOP;
 
-  tex = new Texture();
+  //tex = new Texture();
   material = new Material;
 
@@ -103,17 +103,5 @@
 void MoviePlayer::tick(float time)
 {
-  surface = media_container->getNextFrame();
-
-  if(surface == NULL)
-    texture = NULL;
-  else
-  {
-    bool hasAlpha;
-    SDL_Surface* newSurf = tex->prepareSurface(surface, hasAlpha);
-    if (newSurf != NULL)
-      texture = Texture::loadTexToGL(newSurf);
-    else
-      texture = NULL;
-  }
+  texture = media_container->getNextFrame();
 }
 
Index: /branches/avi_play/src/lib/graphics/importer/movie_player.h
===================================================================
--- /branches/avi_play/src/lib/graphics/importer/movie_player.h	(revision 6316)
+++ /branches/avi_play/src/lib/graphics/importer/movie_player.h	(revision 6317)
@@ -9,5 +9,5 @@
 
 #include "glincl.h"
-#include "sdlincl.h"
+//#include "sdlincl.h"
 
 #include "media_container.h"
@@ -19,12 +19,4 @@
 /* include base_object.h since all classes are derived from this one */
 #include "base_object.h"
-
-/* using namespace std is default, this needs to be here */
-using namespace std;
-
-class MediaContainer;
-class Model;
-class Material;
-class Texture;
 
 /* The state of the MoviePlayer */
@@ -43,7 +35,5 @@
   Model* model;
   Material* material;
-  Texture* tex;
 
-  SDL_Surface* surface;
   GLuint texture;
 
Index: /branches/avi_play/src/lib/graphics/importer/texture_sequence.cc
===================================================================
--- /branches/avi_play/src/lib/graphics/importer/texture_sequence.cc	(revision 6316)
+++ /branches/avi_play/src/lib/graphics/importer/texture_sequence.cc	(revision 6317)
@@ -153,9 +153,9 @@
 }
 
-bool TextureSequence::addFrameList(std::vector<SDL_Surface*> surfaces)
+bool TextureSequence::addFrameList(std::vector<GLuint> textures)
 {
-  // add the surfaces to the list
-  for(int i = 0; i < surfaces.size(); i++)
-    this->addFrame(surfaces[i]);
+  // add the textures to the list
+  for(int i = 0; i < textures.size(); i++)
+    this->addFrame(textures[i]);
 }
 
Index: /branches/avi_play/src/lib/graphics/importer/texture_sequence.h
===================================================================
--- /branches/avi_play/src/lib/graphics/importer/texture_sequence.h	(revision 6316)
+++ /branches/avi_play/src/lib/graphics/importer/texture_sequence.h	(revision 6317)
@@ -30,5 +30,5 @@
     bool addFrame(SDL_Surface* surface);
     bool addFrame(GLuint texture);
-    bool addFrameList(std::vector<SDL_Surface*> surfaces);
+    bool addFrameList(std::vector<GLuint> textures);
 
     virtual bool rebuild();
Index: /branches/avi_play/src/subprojects/importer/movie_player_test.cc
===================================================================
--- /branches/avi_play/src/subprojects/importer/movie_player_test.cc	(revision 6316)
+++ /branches/avi_play/src/subprojects/importer/movie_player_test.cc	(revision 6317)
@@ -36,5 +36,5 @@
 
 void Framework::moduleTick(float dt)
-{
+{ 
   movie_player->tick(dt);
 }
