Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6704 in orxonox.OLD for branches/avi_play/src/lib


Ignore:
Timestamp:
Jan 25, 2006, 3:18:45 PM (19 years ago)
Author:
hdavid
Message:

branches/avi_play: MediaContainer is dummy-safe

Location:
branches/avi_play/src/lib/graphics/importer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/avi_play/src/lib/graphics/importer/media_container.cc

    r6532 r6704  
    4040
    4141  fps = 0;
    42 
    43   if (filename != NULL)
    44   {
    45     if(!this->loadMedia(filename))
    46       PRINTF(1)("MediaContainer::loadMedia() failed for %s\n", filename);
    47   }
     42  mediaLoaded = false;
     43
     44  this->loadMedia(filename);
    4845}
    4946
     
    5451
    5552  fps = 0;
     53  mediaLoaded = false;
    5654}
    5755
     
    6159MediaContainer::~MediaContainer()
    6260{
     61  this->unloadMedia();
     62}
     63
     64void MediaContainer::unloadMedia()
     65{
     66  // check whether a movie is already loaded
     67  if(!mediaLoaded)
     68    return;
     69
     70  fps = 0;
     71
     72  // clear texturelist
     73  this->clearLists();
     74
    6375  if (glIsTexture(texture))
    64     glDeleteTextures(1, &texture);
     76  glDeleteTextures(1, &texture);
    6577
    6678  // Free the RGB image
     
    7688  // Close the video file
    7789  av_close_input_file(format_context);
     90
     91  mediaLoaded = false;
     92
    7893}
    7994
    8095bool MediaContainer::loadMedia(const char* filename)
    8196{
     97  this->unloadMedia();
     98
     99  if(filename == NULL)
     100    return false;
     101  // check whether file exists
     102  if(!ResourceManager::isInDataDir(filename))
     103  {
     104    PRINTF(1)("Could not find %s\n", filename);
     105    return false;
     106  }
     107
     108
     109
    82110  // register all formats and codecs
    83111  av_register_all();
     
    146174  // read the frames and save them in a sequence as textures
    147175  this->loadFrames();
     176  mediaLoaded = true;
    148177
    149178  return true;
  • branches/avi_play/src/lib/graphics/importer/media_container.h

    r6532 r6704  
    4040  int video_stream;
    4141  double fps;
     42  bool mediaLoaded;
    4243
    4344public:
     
    5556 
    5657  GLuint getNextFrame();
    57 
     58  void unloadMedia();
    5859};
    5960
Note: See TracChangeset for help on using the changeset viewer.