Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6112 in orxonox.OLD for branches/avi_play/src/lib


Ignore:
Timestamp:
Dec 14, 2005, 4:23:11 PM (19 years ago)
Author:
stefalie
Message:

branches\avi_play: OpenGL still has problems to display our texture, way too slow

Location:
branches/avi_play/src/lib
Files:
4 edited

Legend:

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

    r6094 r6112  
    9292        PRINTF(1)("current_frame: %i\n", current_frame);
    9393
    94                     // Convert the image from its native format to RGB
     94                    // Convert the image from its native format to RGB
    9595        img_convert((AVPicture*)RGB_frame, PIX_FMT_RGB24, (AVPicture*)frame, codec_context->pix_fmt,
    96                                         codec_context->width, codec_context->height);
     96                                        codec_context->width, codec_context->height);
    9797
    9898        picture = (AVPicture*)RGB_frame;
    99                        
    100         //////////////////////////////////////////////
    101         ////////// FIX THIS //////////////////////////
     99
     100
     101        data = 0;
     102        data = new uint8_t[codec_context->width*codec_context->height*3*sizeof(uint8_t)];
     103        for(int i = 0; i < codec_context->height; i++)
     104          memcpy(&data[i*codec_context->width*3],
     105                 picture->data[0]+i * picture->linesize[0],codec_context->width*sizeof(uint8_t)*3);
     106
     107
    102108        glGenTextures(1, &texture);
    103109        glBindTexture(GL_TEXTURE_2D, texture);
     110        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
     111        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    104112        // if it is the first frame create texture
    105         if(current_frame == 1)
    106         {
    107           glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    108           glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    109                                   // build the texture
    110           glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, codec_context->width, codec_context->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, picture->data[0]);
    111         }
     113        //if(current_frame == 1)
     114        //{
     115          // build the texture
     116        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, codec_context->width, codec_context->height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
     117        //}
    112118        // if its not the first use glTexSubImage2D <-- faster then creating always a new texture
    113         else
    114           glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, codec_context->width, codec_context->height, GL_RGBA, GL_UNSIGNED_BYTE, picture->data[0]);
     119        //else
     120        //  glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, codec_context->width, codec_context->height, GL_RGB, GL_UNSIGNED_BYTE, data);
    115121
    116122
     
    142148  file = fopen(filename, "wb");
    143149  if(file == NULL)
    144         return;
     150        return;
    145151
    146152  // Write header
     
    163169  /* Retrieve stream information */
    164170  if (av_find_stream_info(format_context) < 0)
    165     PRINTF(1)("Could not find stream information in %s\n", filename); 
     171    PRINTF(1)("Could not find stream information in %s\n", filename);
    166172
    167173  // Dump information about file onto standard error
     
    173179  {
    174180    // NOTE: different code for the 0.4.9-pre1 release of ffmpeg (tardis)
    175     // if(format_context->streams[i]->codec.codec_type == CODEC_TYPE_VIDEO)             
     181    // if(format_context->streams[i]->codec.codec_type == CODEC_TYPE_VIDEO)
    176182    if(format_context->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO)
    177183    {
     
    180186    }
    181187  }
    182  
     188
    183189  if(video_stream == -1)
    184190    PRINTF(1)("Could not find a video stream in %s\n", filename);
     
    200206  // Allocate video frame
    201207  frame = avcodec_alloc_frame();
    202         RGB_frame = avcodec_alloc_frame();
     208        RGB_frame = avcodec_alloc_frame();
    203209
    204210  // Determine required buffer size and allocate buffer
     
    207213
    208214  // Assign appropriate parts of buffer to image planes in pFrameRGB
    209   avpicture_fill((AVPicture *)RGB_frame, buffer, PIX_FMT_RGB24, codec_context->width, codec_context->height);   
     215  avpicture_fill((AVPicture *)RGB_frame, buffer, PIX_FMT_RGB24, codec_context->width, codec_context->height);
    210216
    211217}
  • branches/avi_play/src/lib/graphics/importer/media_container.h

    r6094 r6112  
    3232  int num_frames;
    3333  GLuint texture;
     34  uint8_t* data;
    3435
    3536  AVFormatContext* format_context;
     
    4041  AVPicture* picture;
    4142  AVFrame* RGB_frame;
    42        
     43
    4344  int num_bytes;
    4445  uint8_t *buffer;
     
    5354  GLuint getNextFrame();
    5455  void loadMedia(const char* filename);
    55        
     56
    5657  int getHeight();
    5758  int getWidth();
    58         int getCurrentFrame();
     59  int getCurrentFrame();
    5960  int getFrameRate();
    6061  void getStream(/* stream */);
  • branches/avi_play/src/lib/graphics/importer/texture_sequence.cc

    r6094 r6112  
    158158bool TextureSequence::addFrame(GLuint texture)
    159159{
    160   if (texture == NULL)
     160  if (texture == 0)
    161161    return false;
    162162  this->textures.push_back(texture);
    163  
     163
    164164  return true;
    165165}
  • branches/avi_play/src/lib/sound/sound_engine.cc

    r6013 r6112  
    292292  ALubyte deviceName[] =
    293293#else
    294   ALCchar deviceName[] =
     294  ALubyte deviceName[] =
    295295#endif
    296296
Note: See TracChangeset for help on using the changeset viewer.