Changeset 6317 in orxonox.OLD for branches/avi_play
- Timestamp:
- Dec 27, 2005, 2:24:13 PM (19 years ago)
- Location:
- branches/avi_play/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/avi_play/src/lib/graphics/importer/media_container.cc
r6290 r6317 50 50 MediaContainer::~MediaContainer() 51 51 { 52 // delete all surfaces in the list53 while(!this-> surface_list.empty())52 // delete all textures. 53 while(!this->texture_list.empty()) 54 54 { 55 SDL_FreeSurface(this->surface_list.back()); 56 this->surface_list.pop_back(); 55 if (glIsTexture(this->texture_list.back())) 56 glDeleteTextures(1, &this->texture_list.back()); 57 this->texture_list.pop_back(); 57 58 } 59 glDeleteTextures(1, &texture); 58 60 SDL_FreeSurface(surface); 59 61 … … 82 84 83 85 fps = 0; 84 } 85 86 SDL_Surface* MediaContainer::getFrame(int frame_number) 86 frame_num = 0; 87 } 88 89 GLuint MediaContainer::getFrame(int frame_number) 87 90 { 88 91 // seek doesnt work for the first two frames … … 112 115 } 113 116 114 SDL_Surface*MediaContainer::getNextFrame()117 GLuint MediaContainer::getNextFrame() 115 118 { 116 119 /* get next frame */ … … 127 130 packet.data, packet.size); 128 131 132 // Free the packet that was allocated by av_read_frame 133 av_free_packet(&packet); 134 129 135 // Did we get a video frame? 130 136 if(frame_finished) 131 137 { 138 frame_num++; 132 139 //PRINTF(1)("frame_number: %i\n", this->getFrameNumber()); 133 140 // Conversion from YUV to RGB … … 163 170 ); 164 171 165 return surface; 172 // NOTE: use glTexSubImage2D, it's faster!! // 173 /* Create an OpenGL texture from the surface */ 174 glGenTextures(1, &texture); 175 glBindTexture(GL_TEXTURE_2D, texture); 176 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 177 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 178 // build the Texture 179 glTexImage2D(GL_TEXTURE_2D, 180 0, 181 GL_RGB, 182 surface->w, surface->h, 183 0, 184 GL_RGB, 185 GL_UNSIGNED_BYTE, 186 surface->pixels); 187 // build the MipMaps 188 gluBuild2DMipmaps(GL_TEXTURE_2D, 189 GL_RGB, 190 surface->w, 191 surface->h, 192 GL_RGB, 193 GL_UNSIGNED_BYTE, 194 surface->pixels); 195 glBindTexture(GL_TEXTURE_2D, 0); 196 197 return texture; 166 198 } 167 199 } 168 // Free the packet that was allocated by av_read_frame 169 av_free_packet(&packet); 200 else 201 { 202 av_free_packet(&packet); 203 this->getNextFrame(); 204 } 170 205 } 171 206 else … … 173 208 } 174 209 175 vector< SDL_Surface*> MediaContainer::getFrameList()176 { 177 178 while(( surface = this->getNextFrame()) != NULL)179 surface_list.push_back(surface);180 181 return surface_list;210 vector<GLuint> MediaContainer::getFrameList() 211 { 212 213 while((texture = this->getNextFrame()) != NULL) 214 texture_list.push_back(texture); 215 216 return texture_list; 182 217 } 183 218 … … 189 224 190 225 // Open file 191 sprintf(filename, "frame%i.ppm", codec_context->frame_number);226 sprintf(filename, "frame%i.ppm", frame_num); 192 227 file = fopen(filename, "wb"); 193 228 if(file == NULL) … … 264 299 // duration 265 300 duration = format_context->duration / 1000000LL; 301 302 frame_num = 0; 266 303 } 267 304 … … 278 315 int MediaContainer::getFrameNumber() 279 316 { 280 return codec_context->frame_number;317 return frame_num; 281 318 } 282 319 -
branches/avi_play/src/lib/graphics/importer/media_container.h
r6290 r6317 20 20 #include "base_object.h" 21 21 22 #include "glincl.h" 23 22 24 /* using namespace std is default, this needs to be here */ 23 25 using namespace std; … … 30 32 double fps; 31 33 SDL_Surface* surface; 34 GLuint texture; 32 35 uint8_t* data; 33 36 … … 44 47 int video_stream; 45 48 int duration; 49 int frame_num; 46 50 47 vector< SDL_Surface*> surface_list;51 vector<GLuint> texture_list; 48 52 49 53 public: … … 54 58 55 59 void init(); 56 SDL_Surface*getFrame(int frame_number);57 SDL_Surface*getNextFrame();58 vector< SDL_Surface*> getFrameList();60 GLuint getFrame(int frame_number); 61 GLuint getNextFrame(); 62 vector<GLuint> getFrameList(); 59 63 void loadMedia(const char* filename); 60 64 -
branches/avi_play/src/lib/graphics/importer/movie_player.cc
r6290 r6317 58 58 status = STOP; 59 59 60 tex = new Texture();60 //tex = new Texture(); 61 61 material = new Material; 62 62 … … 103 103 void MoviePlayer::tick(float time) 104 104 { 105 surface = media_container->getNextFrame(); 106 107 if(surface == NULL) 108 texture = NULL; 109 else 110 { 111 bool hasAlpha; 112 SDL_Surface* newSurf = tex->prepareSurface(surface, hasAlpha); 113 if (newSurf != NULL) 114 texture = Texture::loadTexToGL(newSurf); 115 else 116 texture = NULL; 117 } 105 texture = media_container->getNextFrame(); 118 106 } 119 107 -
branches/avi_play/src/lib/graphics/importer/movie_player.h
r6290 r6317 9 9 10 10 #include "glincl.h" 11 #include "sdlincl.h"11 //#include "sdlincl.h" 12 12 13 13 #include "media_container.h" … … 19 19 /* include base_object.h since all classes are derived from this one */ 20 20 #include "base_object.h" 21 22 /* using namespace std is default, this needs to be here */23 using namespace std;24 25 class MediaContainer;26 class Model;27 class Material;28 class Texture;29 21 30 22 /* The state of the MoviePlayer */ … … 43 35 Model* model; 44 36 Material* material; 45 Texture* tex;46 37 47 SDL_Surface* surface;48 38 GLuint texture; 49 39 -
branches/avi_play/src/lib/graphics/importer/texture_sequence.cc
r6163 r6317 153 153 } 154 154 155 bool TextureSequence::addFrameList(std::vector< SDL_Surface*> surfaces)155 bool TextureSequence::addFrameList(std::vector<GLuint> textures) 156 156 { 157 // add the surfaces to the list158 for(int i = 0; i < surfaces.size(); i++)159 this->addFrame( surfaces[i]);157 // add the textures to the list 158 for(int i = 0; i < textures.size(); i++) 159 this->addFrame(textures[i]); 160 160 } 161 161 -
branches/avi_play/src/lib/graphics/importer/texture_sequence.h
r6163 r6317 30 30 bool addFrame(SDL_Surface* surface); 31 31 bool addFrame(GLuint texture); 32 bool addFrameList(std::vector< SDL_Surface*> surfaces);32 bool addFrameList(std::vector<GLuint> textures); 33 33 34 34 virtual bool rebuild(); -
branches/avi_play/src/subprojects/importer/movie_player_test.cc
r6290 r6317 36 36 37 37 void Framework::moduleTick(float dt) 38 { 38 { 39 39 movie_player->tick(dt); 40 40 }
Note: See TracChangeset
for help on using the changeset viewer.