diff --git a/polymer/build/include/build.h b/polymer/build/include/build.h index df2f8c7f0..3f23dbc69 100644 --- a/polymer/build/include/build.h +++ b/polymer/build/include/build.h @@ -504,7 +504,7 @@ void hicinit(void); // effect bitset: 1 = greyscale, 2 = invert void hicsetpalettetint(long palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect); // flags bitset: 1 = don't compress -int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, char flags); +int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, float xscale, float yscale, char flags); int hicsetskybox(long picnum, long palnum, char *faces[6]); int hicclearsubst(long picnum, long palnum); diff --git a/polymer/build/include/polymost.h b/polymer/build/include/polymost.h index 7c2d14d85..e6b049aa7 100644 --- a/polymer/build/include/polymost.h +++ b/polymer/build/include/polymost.h @@ -12,7 +12,7 @@ typedef struct hicreplc_t { struct hicreplc_t *next; char palnum, ignore, flags, filler; char *filename; - float alphacut; + float alphacut, xscale, yscale; struct hicskybox_t *skybox; } hicreplctyp; diff --git a/polymer/build/src/defs.c b/polymer/build/src/defs.c index 0a65eeb2a..7103ba03f 100644 --- a/polymer/build/src/defs.c +++ b/polymer/build/src/defs.c @@ -58,7 +58,7 @@ enum { T_SKYBOX, T_FRONT,T_RIGHT,T_BACK,T_LEFT,T_TOP,T_BOTTOM, T_TINT,T_RED,T_GREEN,T_BLUE, - T_TEXTURE,T_ALPHACUT,T_NOCOMPRESS, + T_TEXTURE,T_ALPHACUT,T_XSCALE,T_YSCALE,T_NOCOMPRESS, T_UNDEFMODEL,T_UNDEFMODELRANGE,T_UNDEFMODELOF,T_UNDEFTEXTURE,T_UNDEFTEXTURERANGE, T_ALPHAHACK,T_ALPHAHACKRANGE, T_SPRITECOL,T_2DCOL, @@ -197,9 +197,11 @@ static tokenlist texturetokens[] = { { "glow", T_GLOW }, }; static tokenlist texturetokens_pal[] = { - { "file", T_FILE },{ "name", T_FILE }, - { "alphacut", T_ALPHACUT }, { "detailscale", T_ALPHACUT }, { "scale", T_ALPHACUT }, { "intensity", T_ALPHACUT }, - { "nocompress",T_NOCOMPRESS }, + { "file", T_FILE },{ "name", T_FILE }, + { "alphacut", T_ALPHACUT }, + { "detailscale", T_XSCALE }, { "scale", T_XSCALE }, { "xscale", T_XSCALE }, { "intensity", T_XSCALE }, + { "yscale", T_YSCALE }, + { "nocompress", T_NOCOMPRESS }, }; static int getatoken(scriptfile *sf, tokenlist *tl, int ntokens) @@ -296,7 +298,7 @@ static int defsparser(scriptfile *script) break; } else kclose(i); - hicsetsubsttex(tile,pal,fn,-1.0,0); + hicsetsubsttex(tile,pal,fn,-1.0,1.0,1.0,0); } break; case T_DEFINESKYBOX: @@ -1110,7 +1112,7 @@ static int defsparser(scriptfile *script) char *paltokptr = script->ltextptr, *palend; int pal=-1, i; char *fn = NULL; - double alphacut = -1.0; + double alphacut = -1.0, xscale = 1.0, yscale = 1.0; char flags = 0; if (scriptfile_getsymbol(script,&pal)) break; @@ -1121,6 +1123,10 @@ static int defsparser(scriptfile *script) scriptfile_getstring(script,&fn); break; case T_ALPHACUT: scriptfile_getdouble(script,&alphacut); break; + case T_XSCALE: + scriptfile_getdouble(script,&xscale); break; + case T_YSCALE: + scriptfile_getdouble(script,&yscale); break; case T_NOCOMPRESS: flags |= 1; break; default: @@ -1144,7 +1150,10 @@ static int defsparser(scriptfile *script) break; } else kclose(i); - hicsetsubsttex(tile,pal,fn,alphacut,flags); + xscale = 1.0f / xscale; + yscale = 1.0f / yscale; + + hicsetsubsttex(tile,pal,fn,alphacut,xscale,yscale,flags); } break; case T_DETAIL: case T_GLOW: { char *detailtokptr = script->ltextptr, *detailend; @@ -1158,7 +1167,7 @@ static int defsparser(scriptfile *script) switch (getatoken(script,texturetokens_pal,sizeof(texturetokens_pal)/sizeof(tokenlist))) { case T_FILE: scriptfile_getstring(script,&fn); break; - case T_ALPHACUT: + case T_XSCALE: scriptfile_getdouble(script,¶m); break; case T_NOCOMPRESS: flags |= 1; break; @@ -1186,7 +1195,7 @@ static int defsparser(scriptfile *script) else if (token == T_GLOW) pal = GLOWPAL; - hicsetsubsttex(tile,pal,fn,param,flags); + hicsetsubsttex(tile,pal,fn,-1.0,param,1.0,flags); } break; default: break; diff --git a/polymer/build/src/engine.c b/polymer/build/src/engine.c index dffa053e3..2902c2eaa 100644 --- a/polymer/build/src/engine.c +++ b/polymer/build/src/engine.c @@ -690,7 +690,7 @@ static void scansector(short sectnum); #include "polymost.c" #else void hicsetpalettetint(long palnum, unsigned char r, unsigned char g, unsigned char b, unsigned char effect) { } -int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, char flags) { return 0; } +int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, float xscale, float yscale, char flags) { return 0; } int hicsetskybox(long picnum, long palnum, char *faces[6]) { return 0; } int hicclearsubst(long picnum, long palnum) { return 0; } long polymost_drawtilescreen (long tilex, long tiley, long wallnum, long dimen) { return -1; } diff --git a/polymer/build/src/hightile.c b/polymer/build/src/hightile.c index a377b6495..2757a4689 100644 --- a/polymer/build/src/hightile.c +++ b/polymer/build/src/hightile.c @@ -115,7 +115,7 @@ void hicsetpalettetint(long palnum, unsigned char r, unsigned char g, unsigned c // hicsetsubsttex(picnum,pal,filen,alphacut) // Specifies a replacement graphic file for an ART tile. // -int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, char flags) +int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, float xscale, float yscale, char flags) { hicreplctyp *hr, *hrn; @@ -145,10 +145,9 @@ int hicsetsubsttex(long picnum, long palnum, char *filen, float alphacut, char f return -1; } hrn->ignore = 0; - if (palnum < (MAXPALOOKUPS - RESERVEDPALS)) - hrn->alphacut = min(alphacut,1.0); - else - hrn->alphacut = alphacut; + hrn->alphacut = min(alphacut,1.0); + hrn->xscale = xscale; + hrn->yscale = yscale; hrn->flags = flags; if (hr == NULL) { hrn->next = hicreplc[picnum]; diff --git a/polymer/build/src/polymost.c b/polymer/build/src/polymost.c index 809c9ba57..751b5bc51 100644 --- a/polymer/build/src/polymost.c +++ b/polymer/build/src/polymost.c @@ -1649,6 +1649,16 @@ void drawpoly (double *dpx, double *dpy, long n, long method) bglBindTexture(GL_TEXTURE_2D, pth ? pth->glpic : 0); + // texture scale by parkar request + if (pth && pth->hicr && ((pth->hicr->xscale != 1.0f) || (pth->hicr->yscale != 1.0f))) + { + bglMatrixMode(GL_TEXTURE); + bglLoadIdentity(); + bglScalef(pth->hicr->xscale, pth->hicr->yscale, 1.0f); + bglMatrixMode(GL_MODELVIEW); + } + + // detail texture detailpth = NULL; if (r_detailmapping && usehightile && !r_depthpeeling && !drawingskybox && hicfindsubst(globalpicnum, DETAILPAL, 0)) @@ -1680,7 +1690,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method) bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); - f = detailpth ? detailpth->hicr->alphacut : 1.0; + f = detailpth ? detailpth->hicr->xscale : 1.0; bglMatrixMode(GL_TEXTURE); bglLoadIdentity(); @@ -1690,6 +1700,7 @@ void drawpoly (double *dpx, double *dpy, long n, long method) else detailpth = NULL; + // glow texture glowpth = NULL; if (r_glowmapping && usehightile && !r_depthpeeling && !drawingskybox && hicfindsubst(globalpicnum, GLOWPAL, 0)) @@ -1952,17 +1963,17 @@ void drawpoly (double *dpx, double *dpy, long n, long method) bglEnd(); } - if (texunits > GL_TEXTURE0_ARB) + while (texunits >= GL_TEXTURE0_ARB) { - while (texunits > GL_TEXTURE0_ARB) + bglMatrixMode(GL_TEXTURE); + bglLoadIdentity(); + bglMatrixMode(GL_MODELVIEW); + if (texunits > GL_TEXTURE0_ARB) { - bglMatrixMode(GL_TEXTURE); - bglLoadIdentity(); - bglMatrixMode(GL_MODELVIEW); bglTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.0f); bglDisable(GL_TEXTURE_2D); - bglActiveTextureARB(--texunits); } + bglActiveTextureARB(--texunits); } if (fullbrightdrawingpass == 1) // tile has fullbright colors ?