Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6704 in orxonox.OLD


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

branches/avi_play: MediaContainer is dummy-safe

Location:
branches/avi_play/src
Files:
4 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
  • branches/avi_play/src/world_entities/movie_entity.cc

    r6600 r6704  
    4040  height = 20;
    4141  width = 20;
     42  mediaLoaded = false;
    4243
    4344  this->toList(OM_COMMON);
     
    6465  LoadParam(root, "name", this, MovieEntity, loadMovie);
    6566  LoadParam(root, "axis", this, MovieEntity, setAxis);
    66   LoadParam(root, "rotation", this, MovieEntity, setRotation);
     67  //LoadParam(root, "rotation", this, MovieEntity, setRotation);
    6768  LoadParam(root, "size", this, MovieEntity, setSize);
    6869}
     
    7071void MovieEntity::loadMovie(const char* filename)
    7172{
    72   media_container->loadMedia(filename);
     73  if(media_container->loadMedia(filename))
     74    mediaLoaded = true;
     75  else
     76    mediaLoaded = false;
    7377}
    7478
     
    98102void MovieEntity::tick(float time)
    99103{
     104  if(!mediaLoaded)
     105    return;
     106
    100107  timer += time;
    101108
     
    123130void MovieEntity::draw() const
    124131{
     132  if(!mediaLoaded)
     133    false;
    125134
    126135  glPushMatrix();
  • branches/avi_play/src/world_entities/movie_entity.h

    r6600 r6704  
    2626    float width;
    2727
     28    bool mediaLoaded;
     29
    2830  public:
    2931    MovieEntity (const TiXmlElement* root = NULL);
Note: See TracChangeset for help on using the changeset viewer.