Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

File:
1 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    }
Note: See TracChangeset for help on using the changeset viewer.