Rev 5053 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5053 | Rev 5075 | ||
---|---|---|---|
Line 672... | Line 672... | ||
672 | }
|
672 | }
|
673 | 673 | ||
674 | //Note: even though it says md2model, it works for both md2model&md3model
|
674 | //Note: even though it says md2model, it works for both md2model&md3model
|
675 | int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf) |
675 | int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf) |
676 | {
|
676 | {
|
677 | int32_t i, bpl, xsiz=0, ysiz=0, osizx, osizy, texfmt = GL_RGBA, intexfmt = GL_RGBA; |
677 | int32_t i, bpl, osizx, osizy, texfmt = GL_RGBA, intexfmt = GL_RGBA; |
678 | char *skinfile, hasalpha, fn[BMAX_PATH]; |
678 | char *skinfile, hasalpha, fn[BMAX_PATH]; |
679 | GLuint *texidx = NULL; |
679 | GLuint *texidx = NULL; |
680 | mdskinmap_t *sk, *skzero = NULL; |
680 | mdskinmap_t *sk, *skzero = NULL; |
681 | int32_t doalloc = 1, filh; |
681 | int32_t doalloc = 1, filh; |
682 | int32_t gotcache, picfillen; |
682 | int32_t gotcache, picfillen; |
683 | texcacheheader cachead;
|
683 | texcacheheader cachead;
|
684 | 684 | ||
685 | int32_t startticks, willprint=0; |
685 | int32_t startticks, willprint=0; |
- | 686 | vec2_t siz = { 0, 0 }; |
|
686 | 687 | ||
687 | if (m->mdnum == 2) |
688 | if (m->mdnum == 2) |
688 | surf = 0; |
689 | surf = 0; |
689 | 690 | ||
690 | if ((unsigned)pal >= (unsigned)MAXPALOOKUPS) |
691 | if ((unsigned)pal >= (unsigned)MAXPALOOKUPS) |
Line 774... | Line 775... | ||
774 | 775 | ||
775 | startticks = getticks(); |
776 | startticks = getticks(); |
776 | 777 | ||
777 | gotcache = texcache_readtexheader(fn, picfillen, pal<<8, hicfxmask(pal), &cachead, 1); |
778 | gotcache = texcache_readtexheader(fn, picfillen, pal<<8, hicfxmask(pal), &cachead, 1); |
778 | 779 | ||
779 | if (gotcache && !texcache_loadskin(&cachead, &doalloc, texidx, &xsiz, &ysiz)) |
780 | if (gotcache && !texcache_loadskin(&cachead, &doalloc, texidx, &siz.x, &siz.y)) |
780 | {
|
781 | {
|
781 | osizx = cachead.xdim; |
782 | osizx = cachead.xdim; |
782 | osizy = cachead.ydim; |
783 | osizy = cachead.ydim; |
783 | hasalpha = (cachead.flags & CACHEAD_HASALPHA) ? 1 : 0; |
784 | hasalpha = (cachead.flags & CACHEAD_HASALPHA) ? 1 : 0; |
784 | if (pal < (MAXPALOOKUPS - RESERVEDPALS)) |
785 | if (pal < (MAXPALOOKUPS - RESERVEDPALS)) |
Line 793... | Line 794... | ||
793 | gotcache = 0; // the compressed version will be saved to disk |
794 | gotcache = 0; // the compressed version will be saved to disk |
794 | 795 | ||
795 | if ((filh = kopen4load(fn, 0)) < 0) |
796 | if ((filh = kopen4load(fn, 0)) < 0) |
796 | return -1; |
797 | return -1; |
797 | 798 | ||
798 | ret = daskinloader(filh,&fptr,&bpl,&xsiz,&ysiz,&osizx,&osizy,&hasalpha,pal,hicfxmask(pal)); |
799 | ret = daskinloader(filh,&fptr,&bpl,&siz.x,&siz.y,&osizx,&osizy,&hasalpha,pal,hicfxmask(pal)); |
799 | 800 | ||
800 | if (ret) |
801 | if (ret) |
801 | {
|
802 | {
|
802 | kclose(filh); |
803 | kclose(filh); |
803 | OSD_Printf("Failed loading skin file \"%s\": error %d\n", fn, ret); |
804 | OSD_Printf("Failed loading skin file \"%s\": error %d\n", fn, ret); |
Line 825... | Line 826... | ||
825 | intexfmt = GL_RGB; |
826 | intexfmt = GL_RGB; |
826 | 827 | ||
827 | if (glinfo.bgra) |
828 | if (glinfo.bgra) |
828 | texfmt = GL_BGRA; |
829 | texfmt = GL_BGRA; |
829 | 830 | ||
830 | uploadtexture((doalloc&1), xsiz, ysiz, intexfmt, texfmt, (coltype *)fptr, xsiz, ysiz, DAMETH_HI); |
831 | uploadtexture((doalloc&1), siz, intexfmt, texfmt, (coltype *)fptr, siz, DAMETH_HI); |
831 | Bfree((void *)fptr); |
832 | Bfree((void *)fptr); |
832 | }
|
833 | }
|
833 | 834 | ||
834 | if (!m->skinloaded) |
835 | if (!m->skinloaded) |
835 | {
|
836 | {
|
836 | if (xsiz != osizx || ysiz != osizy) |
837 | if (siz.x != osizx || siz.y != osizy) |
837 | {
|
838 | {
|
838 | float fx, fy; |
839 | float fx, fy; |
839 | fx = ((float)osizx)/((float)xsiz); |
840 | fx = ((float)osizx)/((float)siz.x); |
840 | fy = ((float)osizy)/((float)ysiz); |
841 | fy = ((float)osizy)/((float)siz.y); |
841 | if (m->mdnum == 2) |
842 | if (m->mdnum == 2) |
842 | {
|
843 | {
|
843 | int32_t *lptr; |
844 | int32_t *lptr; |
844 | for (lptr=m->glcmds; (i=*lptr++);) |
845 | for (lptr=m->glcmds; (i=*lptr++);) |
845 | for (i=labs(i); i>0; i--,lptr+=3) |
846 | for (i=labs(i); i>0; i--,lptr+=3) |
Line 877... | Line 878... | ||
877 | bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); |
878 | bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); |
878 | 879 | ||
879 | if (glinfo.texcompr && glusetexcompr && glusetexcache) |
880 | if (glinfo.texcompr && glusetexcompr && glusetexcache) |
880 | if (!gotcache) |
881 | if (!gotcache) |
881 | {
|
882 | {
|
882 | const int32_t nonpow2 = check_nonpow2(xsiz) || check_nonpow2(ysiz); |
883 | const int32_t nonpow2 = check_nonpow2(siz.x) || check_nonpow2(siz.y); |
883 | 884 | ||
884 | // save off the compressed version
|
885 | // save off the compressed version
|
885 | cachead.quality = r_downsize; |
886 | cachead.quality = r_downsize; |
886 | cachead.xdim = osizx>>cachead.quality; |
887 | cachead.xdim = osizx>>cachead.quality; |
887 | cachead.ydim = osizy>>cachead.quality; |
888 | cachead.ydim = osizy>>cachead.quality; |
Line 1558... | Line 1559... | ||
1558 | float norm; |
1559 | float norm; |
1559 | 1560 | ||
1560 | if ((norm = vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]) == 0.f) |
1561 | if ((norm = vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]) == 0.f) |
1561 | return; |
1562 | return; |
1562 | 1563 | ||
1563 | norm = polymost_invsqrt(norm); |
1564 | norm = polymost_invsqrt_approximation(norm); |
1564 | vec[0] *= norm; |
1565 | vec[0] *= norm; |
1565 | vec[1] *= norm; |
1566 | vec[1] *= norm; |
1566 | vec[2] *= norm; |
1567 | vec[2] *= norm; |
1567 | }
|
1568 | }
|
1568 | 1569 | ||
Line 2101... | Line 2102... | ||
2101 | // bglEnable(GL_ALPHA_TEST); bglAlphaFunc(GL_GREATER,0.32);
|
2102 | // bglEnable(GL_ALPHA_TEST); bglAlphaFunc(GL_GREATER,0.32);
|
2102 | // float al = 0.32;
|
2103 | // float al = 0.32;
|
2103 | // PLAG : default cutoff removed
|
2104 | // PLAG : default cutoff removed
|
2104 | float al = 0.0; |
2105 | float al = 0.0; |
2105 | if (alphahackarray[globalpicnum] != 0) |
2106 | if (alphahackarray[globalpicnum] != 0) |
2106 | al=alphahackarray[globalpicnum]; |
2107 | al=alphahackarray[globalpicnum] * (1.f/255.f); |
2107 | bglEnable(GL_BLEND); |
2108 | bglEnable(GL_BLEND); |
2108 | bglEnable(GL_ALPHA_TEST); |
2109 | bglEnable(GL_ALPHA_TEST); |
2109 | bglAlphaFunc(GL_GREATER,al); |
2110 | bglAlphaFunc(GL_GREATER,al); |
2110 | }
|
2111 | }
|
2111 | else
|
2112 | else
|