Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6160 in orxonox.OLD for branches/avi_play/src/lib/graphics/importer


Ignore:
Timestamp:
Dec 19, 2005, 12:43:51 AM (19 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/lib/graphics/importer
Files:
2 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
Note: See TracChangeset for help on using the changeset viewer.