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


A Paste by MrDutchy
1
 
float mixcols (float c1,float c2,float fac)
{
    return ((1.0f-fac) * c1) + (fac * c2);
}

int texture::alphablendtex(texture * tex1, texture * tex2, float alpha)
{
    int c=0;
    
    #ifdef texerrcheck
        if (tex1->channels != tex2->channels) return TC_NONCOMP_ALPHA;
        if (tex1->size != tex2->size) return TC_NONCOMP_SIZE;
    #endif

    for (int x=0; x<size; x++)
    {
        for (int y=0; y<size; y++)
        {
            colarr[c] = clampval(mixcols(tex1->colarr[c],tex2->colarr[c],alpha));
            c++;
            colarr[c] = clampval(mixcols(tex1->colarr[c],tex2->colarr[c],alpha));
            c++;
            colarr[c] = clampval(mixcols(tex1->colarr[c],tex2->colarr[c],alpha));
            c++;
            
            if (channels==TC_RGBA)
            {
                colarr[c] = clampval(mixcols(tex1->colarr[c],tex2->colarr[c],alpha));
                c++;
            }
        }
    }

    return 0;
}