GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


FlipSurface V with SDL by crazylegs
1
 
ST_RESULT
ST_SSPRITE::FlipV() {

    if(_Shadowed == true) {

        if(MainCanvas->LockSurf(_ShadowSurf) != ST_SUCCESS)
            return ST_FAILURE;

        Uint8 *pixelp = (Uint8* ) _ShadowSurf->pixels;
        Uint8 *revp = (Uint8* ) _ShadowSurf->pixels;
        Uint8 *buf = new Uint8[_ShadowSurf->pitch];
        revp += (_ShadowSurf->pitch * (_ShadowSurf->h -1));
        
        for (int i = 0; i < _ShadowSurf->h / 2; i++) {
            memcpy(buf, pixelp, _ShadowSurf->pitch);
            memcpy(pixelp, revp, _ShadowSurf->pitch);
            memcpy(revp, buf, _ShadowSurf->pitch);
            pixelp += _ShadowSurf->pitch;
            revp -= _ShadowSurf->pitch;
        }
        delete [] buf;
        
        MainCanvas->UnLockSurf(_ShadowSurf);
    }

    if(MainCanvas->LockSurf(_IMG) != ST_SUCCESS)
        return ST_FAILURE;

    Uint8 *pixelp = (Uint8* ) _IMG->pixels;
    Uint8 *revp = (Uint8* ) _IMG->pixels;
    Uint8 *buf = new Uint8[_IMG->pitch];
    revp += (_IMG->pitch * (_IMG->h -1));
    
    for (int i = 0; i < _IMG->h / 2; i++) {
        memcpy(buf, pixelp, _IMG->pitch);
        memcpy(pixelp, revp, _IMG->pitch);
        memcpy(revp, buf, _IMG->pitch);
        pixelp += _IMG->pitch;
        revp -= _IMG->pitch;
    }
    delete [] buf;
    
    MainCanvas->UnLockSurf(_IMG);
    

return ST_DONE;
}