Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3343 in orxonox.OLD for orxonox/branches/parenting/src


Ignore:
Timestamp:
Jan 5, 2005, 3:39:08 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/parenting: :texture.cc: swapping textures-cordinates

Location:
orxonox/branches/parenting/src/importer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/parenting/src/importer/texture.cc

    r3341 r3343  
    146146  return NULL;
    147147}
     148
     149inline void Texture::swap (unsigned char &a, unsigned char &b)
     150{
     151  unsigned char temp;
     152  temp = a;
     153  a    = b;
     154  b    = temp;
     155}
     156
    148157
    149158/**
     
    186195      pImage->width  = map->w;
    187196      pImage->data   = (GLubyte*)map->pixels;
     197      pImage->bpp    = 3;//map->BytesPerPixel;
    188198      if( !IMG_isPNG(SDL_RWFromFile(imgNameWithPath, "rb")) && !IMG_isJPG(SDL_RWFromFile(imgNameWithPath, "rb")))
    189199        for (int i=0;i<map->h * map->w *3;i+=3)
     
    193203            pImage->data[i+2] = temp;
    194204          }
     205      /* this is the real swapping algorithm */
     206      for( int i = 0 ; i < (pImage->height / 2) ; ++i )
     207        for( int j = 0 ; j < pImage->width * pImage->bpp; j += pImage->bpp )
     208          for(int k = 0; k < pImage->bpp; ++k)
     209            swap( pImage->data[ (i * pImage->width * pImage->bpp) + j + k], pImage->data[ ( (pImage->height - i - 1) * pImage->width * pImage->bpp ) + j + k]);
     210 
    195211      this->loadTexToGL (pImage, texture);
    196212    }
  • orxonox/branches/parenting/src/importer/texture.h

    r3341 r3343  
    6060    GLuint width;   //!< The width of the Image.
    6161    GLuint height;  //!< The height of the Image.
    62     GLuint bpp;     //!< BitsPerPixel
     62    GLuint bpp;     //!< BytesPerPixel
    6363    GLuint type;    //!< Type of the Image.
    6464    GLubyte *data;  //!< The Image Data comes here! DANGER: uncompressed data.
    6565  };
    6666  char* searchTextureInPaths(char* texName) const;
    67 
     67  inline void swap(unsigned char &a, unsigned char &b);
    6868 public:
    6969
Note: See TracChangeset for help on using the changeset viewer.