Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6160 in orxonox.OLD


Ignore:
Timestamp:
Dec 19, 2005, 12:43:51 AM (18 years ago)
Author:
hdavid
Message:

branches/avi_play: frames are displayed correct and fast…took me only 3 days to find out that the only faut was wrong number in the SDL_CreateRGBSurfaceFrom call :-/

Location:
branches/avi_play/src
Files:
4 edited

Legend:

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

    r6149 r6160  
    4242  fps = 0;
    4343
     44  /* SDL interprets each pixel as a 32-bit number, so our masks must depend
     45     on the endianness (byte order) of the machine */
     46#if SDL_BYTEORDER == SDL_BIG_ENDIAN
     47  rmask = 0xff000000;
     48  gmask = 0x00ff0000;
     49  bmask = 0x0000ff00;
     50#else
     51  rmask = 0x000000ff;
     52  gmask = 0x0000ff00;
     53  bmask = 0x00ff0000;
     54#endif
     55
    4456  if (filename != NULL)
    4557    this->loadMedia(filename);
     
    6880}
    6981
    70 GLuint MediaContainer::getFrame(int frame_number)
    71 {
    72 
    73 }
    74 
    75 SDL_Surface * MediaContainer::getNextFrame()
     82SDL_Surface* MediaContainer::getFrame(int frame_number)
     83{
     84
     85}
     86
     87SDL_Surface* MediaContainer::getNextFrame()
    7688{
    7789  /* get next frame */
     
    107119          memcpy(&data[i*codec_context->width*3], picture->data[0]+i * picture->linesize[0],codec_context->width*sizeof(uint8_t)*3);
    108120
    109 Uint32 rmask, gmask, bmask, amask;
    110 
    111     /* SDL interprets each pixel as a 32-bit number, so our masks must depend
    112        on the endianness (byte order) of the machine */
    113 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
    114     rmask = 0xff000000;
    115     gmask = 0x00ff0000;
    116     bmask = 0x0000ff00;
    117     amask = 0x000000ff;
    118 #else
    119     rmask = 0x000000ff;
    120     gmask = 0x0000ff00;
    121     bmask = 0x00ff0000;
    122     amask = 0xff000000;
    123 #endif
    124 surface = SDL_CreateRGBSurfaceFrom(data, codec_context->width, codec_context->height,
    125                                    32, codec_context->width*sizeof(uint8_t)*3, rmask, gmask, bmask, 0);
    126 
    127 return surface;
    128         /*glGenTextures(1, &texture);
    129         glBindTexture(GL_TEXTURE_2D, texture);
    130         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    131         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    132         // if it is the first frame create texture
    133         //if(current_frame == 1)
    134         //{
    135           // build the texture
    136         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, codec_context->width, codec_context->height, 0, GL_RGB, GL_UNSIGNED_BYTE, picture->data);
    137         //}
    138         // if its not the first use glTexSubImage2D <-- faster then creating always a new texture
    139         //else
    140         //  glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, codec_context->width, codec_context->height, GL_RGB, GL_UNSIGNED_BYTE, data);
    141 
    142 
    143         glBindTexture(GL_TEXTURE_2D, 0);*/
    144         //////////////////////////////////////////////
    145         /////////////////////////////////////////////
    146 
    147         // save frame
    148         //this->saveCurrentFrame();
    149 
    150         //return texture;
     121        surface = SDL_CreateRGBSurfaceFrom(data, codec_context->width, codec_context->height,
     122                                           24, codec_context->width*sizeof(uint8_t)*3, rmask, gmask, bmask, 0);
     123
     124        return surface;
    151125      }
    152126    }
  • branches/avi_play/src/lib/graphics/importer/media_container.h

    r6149 r6160  
    3232
    3333  double fps;
    34   GLuint texture;
     34  Uint32 rmask, gmask, bmask;
    3535  SDL_Surface *surface;
    3636  uint8_t* data;
     
    5353  ~MediaContainer();
    5454
    55   GLuint getFrame(int frame_number);
    56   SDL_Surface * getNextFrame();
     55  SDL_Surface* getFrame(int frame_number);
     56  SDL_Surface* getNextFrame();
    5757  void loadMedia(const char* filename);
    5858
  • branches/avi_play/src/subprojects/importer/importer.cc

    r6127 r6160  
    4040  SDL_Delay(1000);
    4141
    42   // get the frame and save it as an image
    43   //while(movie->getNextFrame() != NULL);       
    44 
    4542}
    4643
     
    6057void Framework::moduleTick(float dt)
    6158{
    62   //while(movie->getNextFrame() != NULL);
    63   //  movie->saveCurrentFrame();       
     59  while(movie->getNextFrame() != NULL);
     60    movie->saveCurrentFrame(); 
    6461}
    6562
  • branches/avi_play/src/subprojects/importer/multitex.cc

    r6149 r6160  
    5252
    5353  seq = new TextureSequence();
    54   //for (int i = 1; i < argc; i++)
    55   //{
    56   //  seq->addFrame(argv[i]);
    57   //  printf("%s\n", argv[i]);
    58   //}
     54  while(seq->addFrame(movie->getNextFrame()) != NULL);
    5955
    60   // add one frame from the movie
    61   //seq->addFrame(movie->getNextFrame());
    62   //GLuint tex;
    63   while(seq->addFrame(movie->getNextFrame()) != NULL)
    64 
    65   test = new Texture(argv[1]);
     56  test = new Texture();
     57 
     58  // ???: Only works if i set as diffuse map an image
     59  // from the avifile created with importer (frameXX.ppm)
    6660  testMat->setDiffuseMap(argv[1]);
    6761
Note: See TracChangeset for help on using the changeset viewer.