Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6094 in orxonox.OLD


Ignore:
Timestamp:
Dec 14, 2005, 1:18:19 AM (18 years ago)
Author:
hdavid
Message:

branches\avi_play: MediaContainer::getNextFrame() try to create a texture from a frame ←- DOES NOT WORK YET, added new function TextureSequence::addFrame(GLuint texture)

Location:
branches/avi_play/src
Files:
6 edited

Legend:

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

    r6068 r6094  
    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,
    9696                                        codec_context->width, codec_context->height);
     97
     98        picture = (AVPicture*)RGB_frame;
    9799                       
     100        //////////////////////////////////////////////
     101        ////////// FIX THIS //////////////////////////
     102        glGenTextures(1, &texture);
     103        glBindTexture(GL_TEXTURE_2D, texture);
     104        // 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        }
     112        // 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]);
     115
     116
     117        glBindTexture(GL_TEXTURE_2D, 0);
     118        //////////////////////////////////////////////
     119        /////////////////////////////////////////////
     120
    98121        // save frame
    99         this->saveCurrentFrame();
    100 
    101 
    102         /* RGB_picture -> texture */
    103 
     122        //this->saveCurrentFrame();
    104123
    105124        return texture;
     
    118137  char filename[32];
    119138  int  y;
    120 
    121   picture = (AVPicture*)RGB_frame;
    122139
    123140  // Open file
     
    183200  // Allocate video frame
    184201  frame = avcodec_alloc_frame();
    185   RGB_frame = avcodec_alloc_frame();
     202        RGB_frame = avcodec_alloc_frame();
    186203
    187204  // Determine required buffer size and allocate buffer
     
    202219{
    203220  return codec_context->width;
     221}
     222
     223int MediaContainer::getCurrentFrame()
     224{
     225  return this->current_frame;
    204226}
    205227
  • branches/avi_play/src/lib/graphics/importer/media_container.h

    r6068 r6094  
    5656  int getHeight();
    5757  int getWidth();
     58        int getCurrentFrame();
    5859  int getFrameRate();
    5960  void getStream(/* stream */);
  • branches/avi_play/src/lib/graphics/importer/texture_sequence.cc

    r5924 r6094  
    152152}
    153153
    154 
     154/**
     155 * @brief adds a new Frame at the end of the Sequence.
     156 * @param texture the texture to add at the end of the Sequence.
     157 */
     158bool TextureSequence::addFrame(GLuint texture)
     159{
     160  if (texture == NULL)
     161    return false;
     162  this->textures.push_back(texture);
     163 
     164  return true;
     165}
    155166
    156167/**
  • branches/avi_play/src/lib/graphics/importer/texture_sequence.h

    r5924 r6094  
    2929    bool addFrame(const char* image);
    3030    bool addFrame(SDL_Surface* surface);
     31    bool addFrame(GLuint texture);
    3132
    3233    virtual bool rebuild();
  • branches/avi_play/src/subprojects/importer/importer.cc

    r6068 r6094  
    6060void Framework::moduleTick(float dt)
    6161{
    62   while(movie->getNextFrame() != NULL);
     62  while(movie->getNextFrame() != NULL)
     63    movie->saveCurrentFrame(); 
    6364}
    6465
  • branches/avi_play/src/subprojects/importer/multitex.cc

    r6068 r6094  
    2929
    3030#include "resource_manager.h"
     31#include "media_container.h"
    3132
    3233Model* obj;
     
    3435Texture* test;
    3536Material* testMat;
     37MediaContainer* movie;
    3638
    3739float counter = 0;
     
    4042void Framework::moduleInit(int argc, char** argv)
    4143{
     44  movie = new MediaContainer("/home/david/Desktop/Face2.avi");
     45
     46  // print information about the media file
     47  movie->printMediaInformation();
     48
    4249  ResourceManager::getInstance()->addImageDir("./");
    4350
     
    5057    printf("%s\n", argv[i]);
    5158  }
     59
     60        // add one frame from the movie
     61        seq->addFrame(movie->getNextFrame());
     62
    5263  test = new Texture(argv[1]);
    5364  testMat->setDiffuseMap(argv[1]);
Note: See TracChangeset for help on using the changeset viewer.