Changeset 6731 in orxonox.OLD for trunk/src/lib/graphics
- Timestamp:
- Jan 25, 2006, 6:46:06 PM (19 years ago)
- Location:
- trunk/src/lib/graphics/importer
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/media_container.cc
r6532 r6731 40 40 41 41 fps = 0; 42 43 if (filename != NULL) 44 { 45 if(!this->loadMedia(filename)) 46 PRINTF(1)("MediaContainer::loadMedia() failed for %s\n", filename); 47 } 48 } 49 50 MediaContainer::MediaContainer() 51 { 52 // set the class id for the base object 53 this->setClassID(CL_MEDIA_CONTAINER, "MediaContainer"); 54 55 fps = 0; 42 mediaLoaded = false; 43 44 this->loadMedia(filename); 56 45 } 57 46 … … 61 50 MediaContainer::~MediaContainer() 62 51 { 52 this->unloadMedia(); 53 } 54 55 void MediaContainer::unloadMedia() 56 { 57 // check whether a movie is already loaded 58 if(!mediaLoaded) 59 return; 60 61 fps = 0; 62 63 // clear texturelist 64 this->clearLists(); 65 63 66 if (glIsTexture(texture)) 64 67 glDeleteTextures(1, &texture); 65 68 66 69 // Free the RGB image … … 76 79 // Close the video file 77 80 av_close_input_file(format_context); 81 82 mediaLoaded = false; 83 78 84 } 79 85 80 86 bool MediaContainer::loadMedia(const char* filename) 81 87 { 88 this->unloadMedia(); 89 90 if(filename == NULL) 91 return false; 92 // check whether file exists 93 if(!ResourceManager::isInDataDir(filename)) 94 { 95 PRINTF(1)("Could not find %s\n", filename); 96 return false; 97 } 98 82 99 // register all formats and codecs 83 100 av_register_all(); … … 146 163 // read the frames and save them in a sequence as textures 147 164 this->loadFrames(); 165 mediaLoaded = true; 148 166 149 167 return true; -
trunk/src/lib/graphics/importer/media_container.h
r6607 r6731 40 40 int video_stream; 41 41 double fps; 42 bool mediaLoaded; 42 43 43 44 public: 44 45 45 MediaContainer(const char* filename); 46 MediaContainer(); 46 MediaContainer(const char* filename = NULL); 47 47 ~MediaContainer(); 48 48 … … 55 55 56 56 GLuint getNextFrame(); 57 57 void unloadMedia(); 58 58 }; 59 59 -
trunk/src/lib/graphics/importer/movie_player.cc
r6600 r6731 33 33 MoviePlayer::MoviePlayer(const char* filename) 34 34 { 35 this->init();36 37 if (filename != NULL) 38 {39 if(!this->loadMovie(filename))40 PRINTF(1)("MoviePlayer::loadMovie() failes for %s\n", filename);41 } 42 } 43 44 MoviePlayer::MoviePlayer() 45 { 46 this->init(); 47 } 35 // set the class id for the base object 36 this->setClassID(CL_MOVIE_PLAYER, "MoviePlayer"); 37 38 status = STOP; 39 timer = 0; 40 frame_number = 0; 41 42 mediaLoaded = false; 43 44 this->loadMovie(filename); 45 46 } 47 48 48 49 49 MoviePlayer::~MoviePlayer() 50 50 { 51 //delete material; 52 //delete model; 51 this->unloadMedia(); 52 } 53 54 void MoviePlayer::unloadMedia() 55 { 56 // check whether a movie is already loaded 57 if(!mediaLoaded) 58 return; 53 59 54 60 if (glIsTexture(texture)) … … 62 68 av_free(frame); 63 69 64 avcodec_default_free_buffers(codec_context);65 66 70 // Close the codec 67 71 avcodec_close(codec_context); … … 69 73 // Close the video file 70 74 av_close_input_file(format_context); 71 }72 73 void MoviePlayer::init()74 {75 // set the class id for the base object76 this->setClassID(CL_MOVIE_PLAYER, "MoviePlayer");77 75 78 76 status = STOP; 79 77 timer = 0; 80 78 frame_number = 0; 81 loading = false; 82 83 /*material = new Material; 84 material->setDiffuseMap("maps/radialTransparency.png"); 85 86 model = new PrimitiveModel(PRIM_PLANE, 10.0); 87 88 LightManager* lightMan = LightManager::getInstance(); 89 lightMan->setAmbientColor(.1,.1,.1); 90 (new Light())->setAbsCoor(5.0, 10.0, 40.0); 91 (new Light())->setAbsCoor(-10, -20, -100); 92 */ 93 } 79 80 mediaLoaded = false; 81 82 } 83 94 84 95 85 bool MoviePlayer::loadMovie(const char* filename) 96 86 { 87 this->unloadMedia(); 88 89 if(filename == NULL) 90 return false; 91 // check whether file exists 92 if(!ResourceManager::isInDataDir(filename)) 93 { 94 PRINTF(1)("Could not find %s\n", filename); 95 return false; 96 } 97 97 98 // register all formats and codecs 98 99 av_register_all(); … … 177 178 glBindTexture(GL_TEXTURE_2D, 0); 178 179 179 loading= true;180 mediaLoaded = true; 180 181 return true; 181 182 } … … 277 278 bool MoviePlayer::gotoFrame(int frames) 278 279 { 279 if(! loading)280 if(!mediaLoaded) 280 281 { 281 282 PRINTF(0)("Load first the media file with loadMovie\n"); … … 344 345 status = PLAY; 345 346 timer = 0; 346 347 this->gotoFrame(start_frame);348 349 PRINTF(0)("start\n");350 347 } 351 348 } … … 354 351 { 355 352 if(status == PAUSE) 356 {357 353 status = PLAY; 358 PRINTF(0)("resume\n");359 }360 354 } 361 355 … … 363 357 { 364 358 if(status == PLAY) 365 {366 359 status = PAUSE; 367 PRINTF(0)("pause\n");368 }369 360 } 370 361 … … 372 363 { 373 364 status = STOP; 374 375 PRINTF(0)("stop\n");376 365 } 377 366 … … 389 378 this->skipFrame(actual_frame - frame_number - 1); 390 379 } 391 //PRINTF(0)("frame_number: %i\n", frame_number); 392 } 393 } 394 395 /*const void MoviePlayer::draw() 396 { 397 material->select(); 398 glBindTexture(GL_TEXTURE_2D, texture); 399 model->draw(); 400 401 LightManager::getInstance()->draw(); 402 }*/ 380 } 381 } 403 382 404 383 GLuint MoviePlayer::getTexture() … … 425 404 void MoviePlayer::printInformation() 426 405 { 427 if(! loading)406 if(!mediaLoaded) 428 407 { 429 408 PRINTF(0)("Load first the media file with loadMovie\n"); -
trunk/src/lib/graphics/importer/movie_player.h
r6607 r6731 17 17 18 18 #include "glincl.h" 19 20 //#include "light.h"21 19 #include "texture.h" 22 //#include "material.h"23 //#include "primitive_model.h"24 20 25 21 // include base_object.h since all classes are derived from this one … … 29 25 typedef enum MP_STATUS { 30 26 PLAY, 31 32 27 PAUSE, 28 STOP 33 29 }; 34 30 … … 37 33 38 34 private: 39 40 //Model* model;41 //Material* material;42 35 43 36 AVFormatContext* format_context; … … 61 54 float fps; 62 55 int duration; 63 bool loading;56 bool mediaLoaded; 64 57 65 58 public: 66 59 67 MoviePlayer(const char* filename); 68 MoviePlayer(); 60 MoviePlayer(const char* filename = NULL); 69 61 ~MoviePlayer(); 70 62 71 63 bool loadMovie(const char* filename); 72 64 73 74 75 76 65 void start(float start_time); 66 void resume(); 67 void pause(); 68 void stop(); 77 69 78 void tick(float dt); 79 //const void draw(); 80 GLuint getTexture(); 70 void tick(float dt); 71 GLuint getTexture(); 81 72 82 83 84 73 void setFPS(float fps); 74 float getFPS(); 75 const MP_STATUS getStatus(); 85 76 void printInformation(); 86 77 87 78 private: 88 79 89 void init();90 80 void getNextFrame(); 91 81 void skipFrame(int frames); 92 82 bool gotoFrame(int frames); 93 83 84 void unloadMedia(); 85 94 86 }; 95 87 96 97 98 88 #endif // _MOVIE_PLAYER
Note: See TracChangeset
for help on using the changeset viewer.