Index: /branches/avi_play/src/lib/graphics/importer/media_container.cc
===================================================================
--- /branches/avi_play/src/lib/graphics/importer/media_container.cc	(revision 6372)
+++ /branches/avi_play/src/lib/graphics/importer/media_container.cc	(revision 6373)
@@ -58,5 +58,5 @@
   if (glIsTexture(texture))
     glDeleteTextures(1, &texture);
-  SDL_FreeSurface(surface);
+  //SDL_FreeSurface(surface);
 
   // Free the RGB image
@@ -186,8 +186,6 @@
                  ((AVPicture*)RGB_frame)->data[0]+i *
                  ((AVPicture*)RGB_frame)->linesize[0], 
-                  codec_context->width*sizeof(uint8_t)*3);
-
-        //avcodec_flush_buffers(codec_context); 
-
+                  codec_context->width*sizeof(uint8_t)*3); 
+/*
         surface = SDL_CreateRGBSurfaceFrom(data, codec_context->width,
                                            codec_context->height,24,
@@ -228,6 +226,32 @@
                         GL_UNSIGNED_BYTE,
                         surface->pixels);
-        glBindTexture(GL_TEXTURE_2D, 0);      
+        glBindTexture(GL_TEXTURE_2D, 0);  */   
+
+        // Create an OpenGL texture
+        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);
+        // create the texture
+        glTexImage2D(GL_TEXTURE_2D,
+                    0,
+                    GL_RGB,
+                    codec_context->width, codec_context->height,
+                    0,
+                    GL_RGB,
+                    GL_UNSIGNED_BYTE,
+                    data);
+        // build the MipMaps
+        gluBuild2DMipmaps(GL_TEXTURE_2D,
+                        GL_RGB,
+                        codec_context->width,
+                        codec_context->height,
+                        GL_RGB,
+                        GL_UNSIGNED_BYTE,
+                        data);
+        glBindTexture(GL_TEXTURE_2D, 0);
         
+        //avcodec_flush_buffers(codec_context);
+
         return texture;
       }
Index: /branches/avi_play/src/lib/graphics/importer/media_container.h
===================================================================
--- /branches/avi_play/src/lib/graphics/importer/media_container.h	(revision 6372)
+++ /branches/avi_play/src/lib/graphics/importer/media_container.h	(revision 6373)
@@ -34,5 +34,5 @@
   AVFrame* RGB_frame;
 
-  SDL_Surface* surface;
+  //SDL_Surface* surface;
   GLuint texture;
   uint8_t* data;
Index: /branches/avi_play/src/lib/graphics/importer/movie_player.cc
===================================================================
--- /branches/avi_play/src/lib/graphics/importer/movie_player.cc	(revision 6372)
+++ /branches/avi_play/src/lib/graphics/importer/movie_player.cc	(revision 6373)
@@ -49,5 +49,5 @@
   if (glIsTexture(texture))
     glDeleteTextures(1, &texture);
-  SDL_FreeSurface(surface);
+  //SDL_FreeSurface(surface);
 
   // Free the RGB image
@@ -57,4 +57,6 @@
   // Free the frame
   av_free(frame);
+
+avcodec_default_free_buffers(codec_context);
 
   // Close the codec
@@ -197,7 +199,5 @@
                  codec_context->width*sizeof(uint8_t)*3);
 
-//avcodec_flush_buffers(codec_context);
-
-        surface = SDL_CreateRGBSurfaceFrom(data, codec_context->width,
+       /* surface = SDL_CreateRGBSurfaceFrom(data, codec_context->width,
                                            codec_context->height,24,
                                            codec_context->width*sizeof(uint8_t)*3,
@@ -229,5 +229,25 @@
                         GL_UNSIGNED_BYTE,
                         surface->pixels);
+        glBindTexture(GL_TEXTURE_2D, 0);*/
+
+
+        glBindTexture(GL_TEXTURE_2D, texture);
+        // update the texture
+        glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
+                          codec_context->width, codec_context->height,
+                          GL_RGB, GL_UNSIGNED_BYTE,
+                          data);
+        // build the MipMaps
+        gluBuild2DMipmaps(GL_TEXTURE_2D,
+                        GL_RGB,
+                        codec_context->width,
+                        codec_context->height,
+                        GL_RGB,
+                        GL_UNSIGNED_BYTE,
+                        data);
         glBindTexture(GL_TEXTURE_2D, 0);
+
+        //avcodec_flush_buffers(codec_context);
+
       }
       else
Index: /branches/avi_play/src/lib/graphics/importer/movie_player.h
===================================================================
--- /branches/avi_play/src/lib/graphics/importer/movie_player.h	(revision 6372)
+++ /branches/avi_play/src/lib/graphics/importer/movie_player.h	(revision 6373)
@@ -48,5 +48,5 @@
   AVFrame* RGB_frame;
 
-  SDL_Surface* surface;
+  //SDL_Surface* surface;
   GLuint texture;
   uint8_t* data;
@@ -89,5 +89,5 @@
   void getNextFrame();
   void skipFrame(int frames);
-  void gotoFrame(int frame);
+  void gotoFrame(int frames);
 
 };
