Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6149 in orxonox.OLD


Ignore:
Timestamp:
Dec 17, 2005, 4:32:29 PM (18 years ago)
Author:
hdavid
Message:

branches\avi_play: textures are displayed fast but not right

Location:
branches/avi_play/src
Files:
4 edited

Legend:

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

    r6127 r6149  
    5252MediaContainer::~MediaContainer()
    5353{
     54
    5455  // Free the RGB image
    5556  delete [] buffer;
     
    7273}
    7374
    74 GLuint MediaContainer::getNextFrame()
     75SDL_Surface * MediaContainer::getNextFrame()
    7576{
    7677  /* get next frame */
     
    9192        PRINTF(1)("frame_number: %i\n", codec_context->frame_number);
    9293
    93         // Convert the image from its native format to RGB
     94        // Conversion from YUV to RGB
     95        // Most codecs return images in YUV 420 format
     96        // (one luminance and two chrominance channels, with the chrominance
     97        // channels samples at half the spatial resolution of the luminance channel)
    9498        img_convert((AVPicture*)RGB_frame, PIX_FMT_RGB24, (AVPicture*)frame, codec_context->pix_fmt,
    9599                                        codec_context->width, codec_context->height);
     
    101105        data = new uint8_t[codec_context->width*codec_context->height*3*sizeof(uint8_t)];
    102106        for(int i = 0; i < codec_context->height; i++)
    103           memcpy(&data[i*codec_context->width*3],
    104                  picture->data[0]+i * picture->linesize[0],codec_context->width*sizeof(uint8_t)*3);
    105 
    106 
    107         glGenTextures(1, &texture);
     107          memcpy(&data[i*codec_context->width*3], picture->data[0]+i * picture->linesize[0],codec_context->width*sizeof(uint8_t)*3);
     108
     109Uint32 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
     124surface = SDL_CreateRGBSurfaceFrom(data, codec_context->width, codec_context->height,
     125                                   32, codec_context->width*sizeof(uint8_t)*3, rmask, gmask, bmask, 0);
     126
     127return surface;
     128        /*glGenTextures(1, &texture);
    108129        glBindTexture(GL_TEXTURE_2D, texture);
    109130        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
     
    113134        //{
    114135          // build the texture
    115         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, codec_context->width, codec_context->height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
     136        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, codec_context->width, codec_context->height, 0, GL_RGB, GL_UNSIGNED_BYTE, picture->data);
    116137        //}
    117138        // if its not the first use glTexSubImage2D <-- faster then creating always a new texture
     
    120141
    121142
    122         glBindTexture(GL_TEXTURE_2D, 0);
     143        glBindTexture(GL_TEXTURE_2D, 0);*/
    123144        //////////////////////////////////////////////
    124145        /////////////////////////////////////////////
     
    127148        //this->saveCurrentFrame();
    128149
    129         return texture;
     150        //return texture;
    130151      }
    131152    }
     
    285306  PRINTF(1)("========================\n");
    286307}
    287 
    288 
    289 //pts = av_q2d(is->video_st->time_base)*pkt->dts;
    290 //pkt = packet
    291 //avstrream = viedo_st
    292 //pts = double
  • branches/avi_play/src/lib/graphics/importer/media_container.h

    r6127 r6149  
    2121#include "base_object.h"
    2222
     23#include <SDL.h>
     24
    2325/* using namespace std is default, this needs to be here */
    2426using namespace std;
     
    3133  double fps;
    3234  GLuint texture;
     35  SDL_Surface *surface;
    3336  uint8_t* data;
    3437
     
    5154
    5255  GLuint getFrame(int frame_number);
    53   GLuint getNextFrame();
     56  SDL_Surface * getNextFrame();
    5457  void loadMedia(const char* filename);
    5558
  • branches/avi_play/src/lib/graphics/importer/texture_sequence.cc

    r6112 r6149  
    149149  }
    150150  this->setAlpha(hasAlpha);
     151
     152  //PRINTF(1)("added frame");
     153
    151154  return true;
    152155}
  • branches/avi_play/src/subprojects/importer/multitex.cc

    r6127 r6149  
    4242void Framework::moduleInit(int argc, char** argv)
    4343{
    44   movie = new MediaContainer("/home/david/Desktop/Face2.avi");
     44  movie = new MediaContainer(argv[2]);
    4545
    4646  // print information about the media file
     
    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  //for (int i = 1; i < argc; i++)
     55  //{
     56  //  seq->addFrame(argv[i]);
     57  //  printf("%s\n", argv[i]);
     58  //}
    5959
    6060  // add one frame from the movie
    61   seq->addFrame(movie->getNextFrame());
    62   GLuint tex;
    63   //while((tex = movie->getNextFrame()) != NULL)
    64   //  seq->addFrame(tex);
     61  //seq->addFrame(movie->getNextFrame());
     62  //GLuint tex;
     63  while(seq->addFrame(movie->getNextFrame()) != NULL)
    6564
    6665  test = new Texture(argv[1]);
     
    102101void Framework::moduleTick(float dt)
    103102{
    104   counter += dt;
     103  counter += 0.2;
    105104
    106105  seq->gotoFrame((unsigned int)counter);
Note: See TracChangeset for help on using the changeset viewer.