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:: Add Line Numbers


A Paste by MrDutchy
int texture::wrap(int zx, int zy)
{
    if (zx<0) zx=size-1; else if (zx>size-1) zx=0;
    if (zy<0) zy=size-1; else if (zy>size-1) zy=0;
    return adress(zx,zy);
}


// then the pixel loop would be like
// looping x,y then:
    for (l=0; l<3; l++)
    {
        total=0;
        // zeile 1
        total+=colarr[wrap(x-1,y-1)+l];
        total+=colarr[wrap(x  ,y-1)+l];
        total+=colarr[wrap(x+1,y-1)+l];
                    
        // zeile 2
        total+=colarr[wrap(x-1,y)  +l];
        total+=colarr[wrap(x  ,y)  +l];
        total+=colarr[wrap(x+1,y)  +l];

        // zeile 3
        total+=colarr[wrap(x-1,y+1)+l];
        total+=colarr[wrap(x  ,y+1)+l];
        total+=colarr[wrap(x+1,y+1)+l];
                    
        tmpcolarr[adress(x,y)+l] = (float)total/9;
    }