mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Moved hightile replacement data into the textures
Not tested yet!
This commit is contained in:
parent
4f8e0dd936
commit
1426ebec20
12 changed files with 196 additions and 453 deletions
|
@ -1330,11 +1330,6 @@ extern int32_t r_rorphase;
|
||||||
void hicinit(void);
|
void hicinit(void);
|
||||||
void hicsetpalettetint(int32_t palnum, char r, char g, char b, char sr, char sg, char sb, polytintflags_t effect);
|
void hicsetpalettetint(int32_t palnum, char r, char g, char b, char sr, char sg, char sb, polytintflags_t effect);
|
||||||
// flags bitset: 1 = don't compress
|
// flags bitset: 1 = don't compress
|
||||||
int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float alphacut,
|
|
||||||
float xscale, float yscale, float specpower, float specfactor, char flags);
|
|
||||||
int32_t hicsetskybox(int32_t picnum, int32_t palnum, char *faces[6], int32_t flags);
|
|
||||||
int32_t hicclearsubst(int32_t picnum, int32_t palnum);
|
|
||||||
|
|
||||||
int32_t Ptile2tile(int32_t tile, int32_t palette) ATTRIBUTE((pure));
|
int32_t Ptile2tile(int32_t tile, int32_t palette) ATTRIBUTE((pure));
|
||||||
int32_t md_loadmodel(const char *fn);
|
int32_t md_loadmodel(const char *fn);
|
||||||
int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, float yoffset, int32_t flags);
|
int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, float yoffset, int32_t flags);
|
||||||
|
|
|
@ -1,19 +1,6 @@
|
||||||
#ifndef HIGHTILE_PRIV_H
|
#ifndef HIGHTILE_PRIV_H
|
||||||
#define HIGHTILE_PRIV_H
|
#define HIGHTILE_PRIV_H
|
||||||
|
|
||||||
struct hicskybox_t {
|
|
||||||
char *face[6];
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct hicreplc_t {
|
|
||||||
struct hicreplc_t *next;
|
|
||||||
char *filename;
|
|
||||||
struct hicskybox_t *skybox;
|
|
||||||
vec2f_t scale;
|
|
||||||
float alphacut, specpower, specfactor;
|
|
||||||
char palnum, flags;
|
|
||||||
} hicreplctyp;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
polytintflags_t f;
|
polytintflags_t f;
|
||||||
uint8_t r, g, b;
|
uint8_t r, g, b;
|
||||||
|
@ -21,27 +8,6 @@ typedef struct {
|
||||||
} polytint_t;
|
} polytint_t;
|
||||||
|
|
||||||
extern polytint_t hictinting[MAXPALOOKUPS];
|
extern polytint_t hictinting[MAXPALOOKUPS];
|
||||||
extern hicreplctyp *hicreplc[MAXTILES];
|
|
||||||
extern int32_t hicinitcounter;
|
|
||||||
|
|
||||||
typedef struct texcachehead_t
|
|
||||||
{
|
|
||||||
char magic[4]; // 'PMST', was 'Polymost'
|
|
||||||
int xdim, ydim; // of image, unpadded
|
|
||||||
int flags; // 1 = !2^x, 2 = has alpha, 4 = lzw compressed
|
|
||||||
int quality; // r_downsize at the time the cache was written
|
|
||||||
} texcacheheader;
|
|
||||||
|
|
||||||
typedef struct texcachepic_t
|
|
||||||
{
|
|
||||||
int size;
|
|
||||||
int format;
|
|
||||||
int xdim, ydim; // of mipmap (possibly padded)
|
|
||||||
int border, depth;
|
|
||||||
} texcachepicture;
|
|
||||||
|
|
||||||
hicreplctyp * hicfindsubst(int picnum, int palnum, int nozero = 0);
|
|
||||||
hicreplctyp * hicfindskybox(int picnum, int palnum, int nozero = 0);
|
|
||||||
|
|
||||||
static inline int have_basepal_tint(void)
|
static inline int have_basepal_tint(void)
|
||||||
{
|
{
|
||||||
|
@ -81,25 +47,11 @@ static inline void globaltinting_apply_ub(uint8_t *color)
|
||||||
color[2] = (uint8_t)(color[2] * (float)globalb * (1.f/255.f));
|
color[2] = (uint8_t)(color[2] * (float)globalb * (1.f/255.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
// texcacheheader cachead.flags bits
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
CACHEAD_NONPOW2 = 1,
|
|
||||||
CACHEAD_HASALPHA = 2,
|
|
||||||
CACHEAD_COMPRESSED = 4,
|
|
||||||
CACHEAD_NODOWNSIZE = 8,
|
|
||||||
CACHEAD_HASFULLBRIGHT = 16,
|
|
||||||
CACHEAD_NPOTWALL = 32,
|
|
||||||
};
|
|
||||||
|
|
||||||
// hicreplctyp hicr->flags bits
|
// replacement flags
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
HICR_NOTEXCOMPRESS = 1,
|
|
||||||
HICR_FORCEFILTER = 2,
|
HICR_FORCEFILTER = 2,
|
||||||
|
|
||||||
HICR_NODOWNSIZE = 16,
|
|
||||||
HICR_ARTIMMUNITY = 32,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// hictinting[].f / gloadtile_hi() and mdloadskin() <effect> arg bits
|
// hictinting[].f / gloadtile_hi() and mdloadskin() <effect> arg bits
|
||||||
|
@ -128,8 +80,4 @@ enum
|
||||||
HICTINT_MEMORY_COMBINATIONS = 1<<5,
|
HICTINT_MEMORY_COMBINATIONS = 1<<5,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GRAYSCALE_COEFF_RED 0.3
|
|
||||||
#define GRAYSCALE_COEFF_GREEN 0.59
|
|
||||||
#define GRAYSCALE_COEFF_BLUE 0.11
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -39,7 +39,7 @@ typedef struct _mdanim_t
|
||||||
|
|
||||||
typedef struct _mdskinmap_t
|
typedef struct _mdskinmap_t
|
||||||
{
|
{
|
||||||
uint8_t palette, flags, filler[2]; // Build palette number, flags the same as hicreplctyp
|
uint8_t palette, flags, filler[2]; // Build palette number, flags the same as hightiles
|
||||||
int32_t skinnum, surfnum; // Skin identifier, surface number
|
int32_t skinnum, surfnum; // Skin identifier, surface number
|
||||||
char *fn; // Skin filename
|
char *fn; // Skin filename
|
||||||
FHardwareTexture *texid[HICTINT_MEMORY_COMBINATIONS]; // OpenGL texture numbers for effect variations
|
FHardwareTexture *texid[HICTINT_MEMORY_COMBINATIONS]; // OpenGL texture numbers for effect variations
|
||||||
|
|
|
@ -149,7 +149,7 @@ typedef struct pthtyp_t
|
||||||
{
|
{
|
||||||
struct pthtyp_t *next;
|
struct pthtyp_t *next;
|
||||||
struct pthtyp_t *ofb; // fullbright pixels
|
struct pthtyp_t *ofb; // fullbright pixels
|
||||||
hicreplctyp *hicr;
|
// *hicr;
|
||||||
|
|
||||||
FHardwareTexture * glpic;
|
FHardwareTexture * glpic;
|
||||||
vec2f_t scale;
|
vec2f_t scale;
|
||||||
|
@ -164,7 +164,7 @@ typedef struct pthtyp_t
|
||||||
} pthtyp;
|
} pthtyp;
|
||||||
|
|
||||||
void gloadtile_art(int32_t dapic, int32_t dameth, pthtyp* pth, int32_t doalloc);
|
void gloadtile_art(int32_t dapic, int32_t dameth, pthtyp* pth, int32_t doalloc);
|
||||||
extern int32_t gloadtile_hi(int32_t,int32_t,int32_t,hicreplctyp *,int32_t,pthtyp *,int32_t, polytintflags_t);
|
extern int32_t gloadtile_hi(int32_t,int32_t,int32_t, int32_t,pthtyp *,int32_t, polytintflags_t);
|
||||||
|
|
||||||
extern int32_t globalnoeffect;
|
extern int32_t globalnoeffect;
|
||||||
extern int32_t drawingskybox;
|
extern int32_t drawingskybox;
|
||||||
|
|
|
@ -361,9 +361,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
if (check_file_exist(fn))
|
if (check_file_exist(fn))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
tileSetHightileReplacement(tile,pal,fn,-1.0,1.0,1.0,1.0,1.0,0);
|
||||||
hicsetsubsttex(tile,pal,fn,-1.0,1.0,1.0,1.0,1.0,0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case T_DEFINESKYBOX:
|
case T_DEFINESKYBOX:
|
||||||
|
@ -382,9 +380,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
happy = 0;
|
happy = 0;
|
||||||
}
|
}
|
||||||
if (i < 6 || !happy) break;
|
if (i < 6 || !happy) break;
|
||||||
#ifdef USE_OPENGL
|
tileSetSkybox(tile, pal, (const char **)fn, 0);
|
||||||
hicsetskybox(tile,pal,fn, 0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case T_DEFINETINT:
|
case T_DEFINETINT:
|
||||||
|
@ -1445,14 +1441,8 @@ static int32_t defsparser(scriptfile *script)
|
||||||
case T_SURF:
|
case T_SURF:
|
||||||
scriptfile_getnumber(script,&surfnum); break;
|
scriptfile_getnumber(script,&surfnum); break;
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
case T_NOCOMPRESS:
|
|
||||||
flags |= HICR_NOTEXCOMPRESS; break;
|
|
||||||
case T_NODOWNSIZE:
|
|
||||||
flags |= HICR_NODOWNSIZE; break;
|
|
||||||
case T_FORCEFILTER:
|
case T_FORCEFILTER:
|
||||||
flags |= HICR_FORCEFILTER; break;
|
flags |= HICR_FORCEFILTER; break;
|
||||||
case T_ARTQUALITY:
|
|
||||||
flags |= HICR_ARTIMMUNITY; break;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1749,9 +1739,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
char *fn[6] = {0,0,0,0,0,0};
|
char *fn[6] = {0,0,0,0,0,0};
|
||||||
char *modelend;
|
char *modelend;
|
||||||
int32_t i, tile = -1, pal = 0, happy = 1;
|
int32_t i, tile = -1, pal = 0, happy = 1;
|
||||||
#ifdef USE_OPENGL
|
int flags = 0;
|
||||||
int32_t flags = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const tokenlist skyboxtokens[] =
|
static const tokenlist skyboxtokens[] =
|
||||||
{
|
{
|
||||||
|
@ -1792,15 +1780,10 @@ static int32_t defsparser(scriptfile *script)
|
||||||
case T_BOTTOM:
|
case T_BOTTOM:
|
||||||
scriptfile_getstring(script,&fn[5]); break;
|
scriptfile_getstring(script,&fn[5]); break;
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
case T_NOCOMPRESS:
|
case T_FORCEFILTER:
|
||||||
flags |= HICR_NOTEXCOMPRESS; break;
|
flags |= HICR_FORCEFILTER; break;
|
||||||
case T_NODOWNSIZE:
|
|
||||||
flags |= HICR_NODOWNSIZE; break;
|
|
||||||
case T_FORCEFILTER:
|
|
||||||
flags |= HICR_FORCEFILTER; break;
|
|
||||||
case T_ARTQUALITY:
|
|
||||||
flags |= HICR_ARTIMMUNITY; break;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1814,9 +1797,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
}
|
}
|
||||||
if (!happy) break;
|
if (!happy) break;
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
tileSetSkybox(tile, pal, (const char **)fn, flags);
|
||||||
hicsetskybox(tile,pal,fn, flags);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case T_HIGHPALOOKUP:
|
case T_HIGHPALOOKUP:
|
||||||
|
@ -2065,9 +2046,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
int32_t pal=-1, xsiz = 0, ysiz = 0;
|
int32_t pal=-1, xsiz = 0, ysiz = 0;
|
||||||
char *fn = NULL;
|
char *fn = NULL;
|
||||||
double alphacut = -1.0, xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0;
|
double alphacut = -1.0, xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0;
|
||||||
#ifdef USE_OPENGL
|
uint8_t flags = 0;
|
||||||
char flags = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const tokenlist texturetokens_pal[] =
|
static const tokenlist texturetokens_pal[] =
|
||||||
{
|
{
|
||||||
|
@ -2102,16 +2081,6 @@ static int32_t defsparser(scriptfile *script)
|
||||||
scriptfile_getdouble(script,&specpower); break;
|
scriptfile_getdouble(script,&specpower); break;
|
||||||
case T_SPECFACTOR:
|
case T_SPECFACTOR:
|
||||||
scriptfile_getdouble(script,&specfactor); break;
|
scriptfile_getdouble(script,&specfactor); break;
|
||||||
#ifdef USE_OPENGL
|
|
||||||
case T_NOCOMPRESS:
|
|
||||||
flags |= HICR_NOTEXCOMPRESS; break;
|
|
||||||
case T_NODOWNSIZE:
|
|
||||||
flags |= HICR_NODOWNSIZE; break;
|
|
||||||
case T_FORCEFILTER:
|
|
||||||
flags |= HICR_FORCEFILTER; break;
|
|
||||||
case T_ARTQUALITY:
|
|
||||||
flags |= HICR_ARTIMMUNITY; break;
|
|
||||||
#endif
|
|
||||||
case T_ORIGSIZEX:
|
case T_ORIGSIZEX:
|
||||||
scriptfile_getnumber(script, &xsiz);
|
scriptfile_getnumber(script, &xsiz);
|
||||||
break;
|
break;
|
||||||
|
@ -2144,21 +2113,17 @@ static int32_t defsparser(scriptfile *script)
|
||||||
{
|
{
|
||||||
tileSetDummy(tile, xsiz, ysiz);
|
tileSetDummy(tile, xsiz, ysiz);
|
||||||
}
|
}
|
||||||
#ifdef USE_OPENGL
|
|
||||||
xscale = 1.0f / xscale;
|
xscale = 1.0f / xscale;
|
||||||
yscale = 1.0f / yscale;
|
yscale = 1.0f / yscale;
|
||||||
|
|
||||||
hicsetsubsttex(tile,pal,fn,alphacut,xscale,yscale, specpower, specfactor,flags);
|
tileSetHightileReplacement(tile,pal,fn,alphacut,xscale,yscale, specpower, specfactor,flags);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case T_DETAIL: case T_GLOW: case T_SPECULAR: case T_NORMAL:
|
case T_DETAIL: case T_GLOW: case T_SPECULAR: case T_NORMAL:
|
||||||
{
|
{
|
||||||
char *detailtokptr = script->ltextptr, *detailend;
|
char *detailtokptr = script->ltextptr, *detailend;
|
||||||
#ifdef USE_OPENGL
|
|
||||||
int32_t pal = 0;
|
int32_t pal = 0;
|
||||||
char flags = 0;
|
char flags = 0;
|
||||||
#endif
|
|
||||||
char *fn = NULL;
|
char *fn = NULL;
|
||||||
double xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0;
|
double xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0;
|
||||||
|
|
||||||
|
@ -2191,16 +2156,6 @@ static int32_t defsparser(scriptfile *script)
|
||||||
scriptfile_getdouble(script,&specpower); break;
|
scriptfile_getdouble(script,&specpower); break;
|
||||||
case T_SPECFACTOR:
|
case T_SPECFACTOR:
|
||||||
scriptfile_getdouble(script,&specfactor); break;
|
scriptfile_getdouble(script,&specfactor); break;
|
||||||
#ifdef USE_OPENGL
|
|
||||||
case T_NOCOMPRESS:
|
|
||||||
flags |= HICR_NOTEXCOMPRESS; break;
|
|
||||||
case T_NODOWNSIZE:
|
|
||||||
flags |= HICR_NODOWNSIZE; break;
|
|
||||||
case T_FORCEFILTER:
|
|
||||||
flags |= HICR_FORCEFILTER; break;
|
|
||||||
case T_ARTQUALITY:
|
|
||||||
flags |= HICR_ARTIMMUNITY; break;
|
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2217,7 +2172,6 @@ static int32_t defsparser(scriptfile *script)
|
||||||
if (EDUKE32_PREDICT_FALSE(check_file_exist(fn)))
|
if (EDUKE32_PREDICT_FALSE(check_file_exist(fn)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
|
||||||
switch (token)
|
switch (token)
|
||||||
{
|
{
|
||||||
case T_DETAIL:
|
case T_DETAIL:
|
||||||
|
@ -2235,8 +2189,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
pal = NORMALPAL;
|
pal = NORMALPAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
hicsetsubsttex(tile,pal,fn,-1.0f,xscale,yscale, specpower, specfactor,flags);
|
tileSetHightileReplacement(tile,pal,fn,-1.0f,xscale,yscale, specpower, specfactor,flags);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -2308,10 +2261,6 @@ static int32_t defsparser(scriptfile *script)
|
||||||
case T_UNDEFTEXTURERANGE:
|
case T_UNDEFTEXTURERANGE:
|
||||||
{
|
{
|
||||||
int32_t r0,r1;
|
int32_t r0,r1;
|
||||||
#ifdef USE_OPENGL
|
|
||||||
int32_t i;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (EDUKE32_PREDICT_FALSE(scriptfile_getsymbol(script,&r0))) break;
|
if (EDUKE32_PREDICT_FALSE(scriptfile_getsymbol(script,&r0))) break;
|
||||||
if (tokn == T_UNDEFTEXTURERANGE)
|
if (tokn == T_UNDEFTEXTURERANGE)
|
||||||
{
|
{
|
||||||
|
@ -2327,12 +2276,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
if (EDUKE32_PREDICT_FALSE(check_tile("undeftexture", r0, script, cmdtokptr)))
|
if (EDUKE32_PREDICT_FALSE(check_tile("undeftexture", r0, script, cmdtokptr)))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
for (; r0 <= r1; r0++) tileRemoveReplacement(r0);
|
||||||
#ifdef USE_OPENGL
|
|
||||||
for (; r0 <= r1; r0++)
|
|
||||||
for (i=MAXPALOOKUPS-1; i>=0; i--)
|
|
||||||
hicclearsubst(r0,i);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -8197,7 +8197,6 @@ int32_t engineInit(void)
|
||||||
paletteLoadFromDisk();
|
paletteLoadFromDisk();
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
if (!hicinitcounter) hicinit();
|
|
||||||
if (!mdinited) mdinit();
|
if (!mdinited) mdinit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "kplib.h"
|
#include "kplib.h"
|
||||||
#include "hightile.h"
|
#include "hightile.h"
|
||||||
|
@ -16,56 +13,6 @@
|
||||||
|
|
||||||
polytint_t hictinting[MAXPALOOKUPS];
|
polytint_t hictinting[MAXPALOOKUPS];
|
||||||
|
|
||||||
hicreplctyp *hicreplc[MAXTILES];
|
|
||||||
int32_t hicinitcounter = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
// find the index into hicreplc[] which contains the replacement tile particulars
|
|
||||||
//
|
|
||||||
hicreplctyp *hicfindsubst(int picnum, int palnum, int nozero)
|
|
||||||
{
|
|
||||||
if (!hicreplc[picnum] || !hicinitcounter) return NULL;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
hicreplctyp *hr = hicreplc[picnum];
|
|
||||||
for (; hr; hr = hr->next)
|
|
||||||
if (hr->palnum == palnum)
|
|
||||||
return hr;
|
|
||||||
|
|
||||||
if (!palnum || nozero)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
palnum = 0;
|
|
||||||
} while (1);
|
|
||||||
|
|
||||||
return NULL; // no replacement found
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// this is separate because it's not worth passing an extra parameter which is "0" in 99.9999% of cases
|
|
||||||
// to the regular hicfindsubst() function
|
|
||||||
//
|
|
||||||
hicreplctyp *hicfindskybox(int picnum, int palnum, int nozero)
|
|
||||||
{
|
|
||||||
if (!hicreplc[picnum] || !hicinitcounter) return NULL;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
hicreplctyp *hr = hicreplc[picnum];
|
|
||||||
for (; hr; hr = hr->next)
|
|
||||||
if (hr->skybox && hr->palnum == palnum)
|
|
||||||
return hr;
|
|
||||||
|
|
||||||
if (!palnum || nozero)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
palnum = 0;
|
|
||||||
} while (1);
|
|
||||||
|
|
||||||
return NULL; // no replacement found
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// hicinit()
|
// hicinit()
|
||||||
|
@ -81,36 +28,6 @@ void hicinit(void)
|
||||||
tint.r = tint.g = tint.b = 0xff;
|
tint.r = tint.g = tint.b = 0xff;
|
||||||
tint.f = 0;
|
tint.f = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hicinitcounter)
|
|
||||||
{
|
|
||||||
hicreplctyp *hr, *next;
|
|
||||||
int32_t j;
|
|
||||||
|
|
||||||
for (i=MAXTILES-1; i>=0; i--)
|
|
||||||
{
|
|
||||||
for (hr=hicreplc[i]; hr;)
|
|
||||||
{
|
|
||||||
next = hr->next;
|
|
||||||
|
|
||||||
if (hr->skybox)
|
|
||||||
{
|
|
||||||
for (j=5; j>=0; j--)
|
|
||||||
Xfree(hr->skybox->face[j]);
|
|
||||||
Xfree(hr->skybox);
|
|
||||||
}
|
|
||||||
|
|
||||||
Xfree(hr->filename);
|
|
||||||
Xfree(hr);
|
|
||||||
|
|
||||||
hr = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Bmemset(hicreplc,0,sizeof(hicreplc));
|
|
||||||
|
|
||||||
hicinitcounter++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,7 +40,6 @@ void hicinit(void)
|
||||||
void hicsetpalettetint(int32_t palnum, char r, char g, char b, char sr, char sg, char sb, polytintflags_t effect)
|
void hicsetpalettetint(int32_t palnum, char r, char g, char b, char sr, char sg, char sb, polytintflags_t effect)
|
||||||
{
|
{
|
||||||
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return;
|
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return;
|
||||||
if (!hicinitcounter) hicinit();
|
|
||||||
|
|
||||||
polytint_t & tint = hictinting[palnum];
|
polytint_t & tint = hictinting[palnum];
|
||||||
tint.r = r;
|
tint.r = r;
|
||||||
|
@ -136,191 +52,4 @@ void hicsetpalettetint(int32_t palnum, char r, char g, char b, char sr, char sg,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// hicsetsubsttex(picnum,pal,filen,alphacut)
|
|
||||||
// Specifies a replacement graphic file for an ART tile.
|
|
||||||
//
|
|
||||||
int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float alphacut, float xscale, float yscale, float specpower, float specfactor, char flags)
|
|
||||||
{
|
|
||||||
hicreplctyp *hr, *hrn;
|
|
||||||
|
|
||||||
if ((uint32_t)picnum >= (uint32_t)MAXTILES) return -1;
|
|
||||||
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return -1;
|
|
||||||
if (!hicinitcounter) hicinit();
|
|
||||||
|
|
||||||
for (hr = hicreplc[picnum]; hr; hr = hr->next)
|
|
||||||
{
|
|
||||||
if (hr->palnum == palnum)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hr)
|
|
||||||
{
|
|
||||||
// no replacement yet defined
|
|
||||||
hrn = (hicreplctyp *)Xcalloc(1,sizeof(hicreplctyp));
|
|
||||||
hrn->palnum = palnum;
|
|
||||||
}
|
|
||||||
else hrn = hr;
|
|
||||||
|
|
||||||
// store into hicreplc the details for this replacement
|
|
||||||
Xfree(hrn->filename);
|
|
||||||
|
|
||||||
hrn->filename = Xstrdup(filen);
|
|
||||||
hrn->alphacut = min(alphacut,1.f);
|
|
||||||
hrn->scale.x = xscale;
|
|
||||||
hrn->scale.y = yscale;
|
|
||||||
hrn->specpower = specpower;
|
|
||||||
hrn->specfactor = specfactor;
|
|
||||||
hrn->flags = flags;
|
|
||||||
if (hr == NULL)
|
|
||||||
{
|
|
||||||
hrn->next = hicreplc[picnum];
|
|
||||||
hicreplc[picnum] = hrn;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tilesiz[picnum].x<=0 || tilesiz[picnum].y<=0)
|
|
||||||
{
|
|
||||||
static int32_t first=1;
|
|
||||||
if (first)
|
|
||||||
{
|
|
||||||
initprintf("Warning: defined hightile replacement for empty tile %d.", picnum);
|
|
||||||
initprintf(" Maybe some tilesXXX.art are not loaded?");
|
|
||||||
initprintf("\n");
|
|
||||||
first = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//printf("Replacement [%d,%d]: %s\n", picnum, palnum, hicreplc[i]->filename);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// hicsetskybox(picnum,pal,faces[6])
|
|
||||||
// Specifies a graphic files making up a skybox.
|
|
||||||
//
|
|
||||||
int32_t hicsetskybox( int32_t picnum, int32_t palnum, char *faces[6], int32_t flags )
|
|
||||||
{
|
|
||||||
hicreplctyp *hr, *hrn;
|
|
||||||
int32_t j;
|
|
||||||
|
|
||||||
if ((uint32_t)picnum >= (uint32_t)MAXTILES) return -1;
|
|
||||||
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return -1;
|
|
||||||
for (j=5; j>=0; j--) if (!faces[j]) return -1;
|
|
||||||
if (!hicinitcounter) hicinit();
|
|
||||||
|
|
||||||
for (hr = hicreplc[picnum]; hr; hr = hr->next)
|
|
||||||
{
|
|
||||||
if (hr->palnum == palnum)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hr)
|
|
||||||
{
|
|
||||||
// no replacement yet defined
|
|
||||||
hrn = (hicreplctyp *)Xcalloc(1,sizeof(hicreplctyp));
|
|
||||||
hrn->palnum = palnum;
|
|
||||||
}
|
|
||||||
else hrn = hr;
|
|
||||||
|
|
||||||
if (!hrn->skybox)
|
|
||||||
hrn->skybox = (struct hicskybox_t *)Xcalloc(1,sizeof(struct hicskybox_t));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (j=0; j<6; j++)
|
|
||||||
DO_FREE_AND_NULL(hrn->skybox->face[j]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// store each face's filename
|
|
||||||
for (j=0; j<6; j++)
|
|
||||||
hrn->skybox->face[j] = Xstrdup(faces[j]);
|
|
||||||
|
|
||||||
hrn->flags = flags;
|
|
||||||
|
|
||||||
if (hr == NULL)
|
|
||||||
{
|
|
||||||
hrn->next = hicreplc[picnum];
|
|
||||||
hicreplc[picnum] = hrn;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// hicclearsubst(picnum,pal)
|
|
||||||
// Clears a replacement for an ART tile, including skybox faces.
|
|
||||||
//
|
|
||||||
int32_t hicclearsubst(int32_t picnum, int32_t palnum)
|
|
||||||
{
|
|
||||||
hicreplctyp *hr, *hrn = NULL;
|
|
||||||
|
|
||||||
if ((uint32_t)picnum >= (uint32_t)MAXTILES) return -1;
|
|
||||||
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return -1;
|
|
||||||
if (!hicinitcounter) return 0;
|
|
||||||
|
|
||||||
for (hr = hicreplc[picnum]; hr; hrn = hr, hr = hr->next)
|
|
||||||
{
|
|
||||||
if (hr->palnum == palnum)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hr) return 0;
|
|
||||||
|
|
||||||
Xfree(hr->filename);
|
|
||||||
if (hr->skybox)
|
|
||||||
{
|
|
||||||
int32_t i;
|
|
||||||
for (i=5; i>=0; i--)
|
|
||||||
Xfree(hr->skybox->face[i]);
|
|
||||||
Xfree(hr->skybox);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hrn) hrn->next = hr->next;
|
|
||||||
else hicreplc[picnum] = hr->next;
|
|
||||||
Xfree(hr);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* USE_OPENGL */
|
|
||||||
|
|
||||||
#include "compat.h"
|
|
||||||
|
|
||||||
void hicsetpalettetint(int32_t palnum, char r, char g, char b, char sr, char sg, char sb, polytintflags_t effect)
|
|
||||||
{
|
|
||||||
UNREFERENCED_PARAMETER(palnum);
|
|
||||||
UNREFERENCED_PARAMETER(r);
|
|
||||||
UNREFERENCED_PARAMETER(g);
|
|
||||||
UNREFERENCED_PARAMETER(b);
|
|
||||||
UNREFERENCED_PARAMETER(sr);
|
|
||||||
UNREFERENCED_PARAMETER(sg);
|
|
||||||
UNREFERENCED_PARAMETER(sb);
|
|
||||||
UNREFERENCED_PARAMETER(effect);
|
|
||||||
}
|
|
||||||
int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float alphacut)
|
|
||||||
{
|
|
||||||
UNREFERENCED_PARAMETER(picnum);
|
|
||||||
UNREFERENCED_PARAMETER(palnum);
|
|
||||||
UNREFERENCED_PARAMETER(filen);
|
|
||||||
UNREFERENCED_PARAMETER(alphacut);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int32_t hicsetskybox(int32_t picnum, int32_t palnum, char *faces[6], int32_t flags)
|
|
||||||
{
|
|
||||||
UNREFERENCED_PARAMETER(picnum);
|
|
||||||
UNREFERENCED_PARAMETER(palnum);
|
|
||||||
UNREFERENCED_PARAMETER(faces);
|
|
||||||
UNREFERENCED_PARAMETER(flags);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int32_t hicclearsubst(int32_t picnum, int32_t palnum)
|
|
||||||
{
|
|
||||||
UNREFERENCED_PARAMETER(picnum);
|
|
||||||
UNREFERENCED_PARAMETER(palnum);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
|
@ -513,18 +513,9 @@ int32_t polymost_maskWallHasTranslucency(uwalltype const * const wall)
|
||||||
if (wall->cstat & CSTAT_WALL_TRANSLUCENT)
|
if (wall->cstat & CSTAT_WALL_TRANSLUCENT)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
//POGO: only hightiles may have translucency in their texture
|
auto tex = TileFiles.tiles[wall->picnum];
|
||||||
if (!usehightile)
|
auto si = tex->FindReplacement(wall->pal);
|
||||||
return false;
|
if (si && usehightile) tex = si->faces[0];
|
||||||
|
|
||||||
hicreplctyp* si = hicfindsubst(wall->picnum, wall->pal, hictinting[wall->pal].f & HICTINT_ALWAYSUSEART);
|
|
||||||
if (!si) return false; // regular tiles have no translucency
|
|
||||||
|
|
||||||
uint8_t pal = wall->pal;
|
|
||||||
if (palookup[pal] == NULL)
|
|
||||||
pal = 0;
|
|
||||||
|
|
||||||
auto tex = TileFiles.GetTexture(si->filename);
|
|
||||||
return tex && tex->GetTranslucency();
|
return tex && tex->GetTranslucency();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,18 +525,9 @@ int32_t polymost_spriteHasTranslucency(uspritetype const * const tspr)
|
||||||
((unsigned)tspr->owner < MAXSPRITES && spriteext[tspr->owner].alpha))
|
((unsigned)tspr->owner < MAXSPRITES && spriteext[tspr->owner].alpha))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
//POGO: only hightiles may have translucency in their texture
|
auto tex = TileFiles.tiles[tspr->picnum];
|
||||||
if (!usehightile)
|
auto si = tex->FindReplacement(tspr->shade, hictinting[tspr->shade].f & HICTINT_ALWAYSUSEART);
|
||||||
return false;
|
if (si && usehightile) tex = si->faces[0];
|
||||||
|
|
||||||
hicreplctyp* si = hicfindsubst(tspr->picnum, tspr->shade, hictinting[tspr->shade].f & HICTINT_ALWAYSUSEART);
|
|
||||||
if (!si) return false; // regular tiles have no translucency
|
|
||||||
|
|
||||||
uint8_t pal = tspr->shade;
|
|
||||||
if (palookup[pal] == NULL)
|
|
||||||
pal = 0;
|
|
||||||
|
|
||||||
auto tex = TileFiles.GetTexture(si->filename);
|
|
||||||
return tex && tex->GetTranslucency();
|
return tex && tex->GetTranslucency();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2076,8 +2058,7 @@ static void polymost_internal_nonparallaxed(vec2f_t n0, vec2f_t n1, float ryp0,
|
||||||
drawpoly_alpha = 0.f;
|
drawpoly_alpha = 0.f;
|
||||||
drawpoly_blend = 0;
|
drawpoly_blend = 0;
|
||||||
|
|
||||||
//if ((usehightile && hicfindsubst(globalpicnum, globalpal, hictinting[globalpal].f & HICTINT_ALWAYSUSEART)))
|
calc_and_apply_fog(fogshade(global_cf_shade, global_cf_pal), sec->visibility, POLYMOST_CHOOSE_FOG_PAL(global_cf_fogpal, global_cf_pal));
|
||||||
calc_and_apply_fog(fogshade(global_cf_shade, global_cf_pal), sec->visibility, POLYMOST_CHOOSE_FOG_PAL(global_cf_fogpal, global_cf_pal));
|
|
||||||
|
|
||||||
if (have_floor)
|
if (have_floor)
|
||||||
{
|
{
|
||||||
|
@ -2544,9 +2525,7 @@ static void polymost_drawalls(int32_t const bunch)
|
||||||
}
|
}
|
||||||
else if ((nextsectnum < 0) || (!(sector[nextsectnum].floorstat&1)))
|
else if ((nextsectnum < 0) || (!(sector[nextsectnum].floorstat&1)))
|
||||||
{
|
{
|
||||||
//Parallaxing sky... hacked for Ken's mountain texture
|
calc_and_apply_fog_factor(sec->floorshade, sec->visibility, sec->floorpal, 0.005f);
|
||||||
//if ((usehightile && hicfindsubst(globalpicnum, globalpal, hictinting[globalpal].f & HICTINT_ALWAYSUSEART)))
|
|
||||||
calc_and_apply_fog_factor(sec->floorshade, sec->visibility, sec->floorpal, 0.005f);
|
|
||||||
|
|
||||||
globvis2 = globalpisibility;
|
globvis2 = globalpisibility;
|
||||||
if (sec->visibility != 0)
|
if (sec->visibility != 0)
|
||||||
|
@ -2806,9 +2785,7 @@ static void polymost_drawalls(int32_t const bunch)
|
||||||
}
|
}
|
||||||
else if ((nextsectnum < 0) || (!(sector[nextsectnum].ceilingstat&1)))
|
else if ((nextsectnum < 0) || (!(sector[nextsectnum].ceilingstat&1)))
|
||||||
{
|
{
|
||||||
//Parallaxing sky... hacked for Ken's mountain texture
|
calc_and_apply_fog_factor(sec->ceilingshade, sec->visibility, sec->ceilingpal, 0.005f);
|
||||||
//if ((usehightile && hicfindsubst(globalpicnum, globalpal, hictinting[globalpal].f & HICTINT_ALWAYSUSEART)))
|
|
||||||
calc_and_apply_fog_factor(sec->ceilingshade, sec->visibility, sec->ceilingpal, 0.005f);
|
|
||||||
|
|
||||||
globvis2 = globalpisibility;
|
globvis2 = globalpisibility;
|
||||||
if (sec->visibility != 0)
|
if (sec->visibility != 0)
|
||||||
|
@ -3122,8 +3099,7 @@ static void polymost_drawalls(int32_t const bunch)
|
||||||
}
|
}
|
||||||
if (wal->cstat&256) { xtex.v = -xtex.v; ytex.v = -ytex.v; otex.v = -otex.v; } //yflip
|
if (wal->cstat&256) { xtex.v = -xtex.v; ytex.v = -ytex.v; otex.v = -otex.v; } //yflip
|
||||||
|
|
||||||
//if ((usehightile && hicfindsubst(globalpicnum, globalpal, hictinting[globalpal].f & HICTINT_ALWAYSUSEART)))
|
calc_and_apply_fog(fogshade(wal->shade, wal->pal), sec->visibility, get_floor_fogpal(sec));
|
||||||
calc_and_apply_fog(fogshade(wal->shade, wal->pal), sec->visibility, get_floor_fogpal(sec));
|
|
||||||
|
|
||||||
pow2xsplit = 1;
|
pow2xsplit = 1;
|
||||||
#ifdef YAX_ENABLE
|
#ifdef YAX_ENABLE
|
||||||
|
@ -3167,8 +3143,7 @@ static void polymost_drawalls(int32_t const bunch)
|
||||||
}
|
}
|
||||||
if (nwal->cstat&256) { xtex.v = -xtex.v; ytex.v = -ytex.v; otex.v = -otex.v; } //yflip
|
if (nwal->cstat&256) { xtex.v = -xtex.v; ytex.v = -ytex.v; otex.v = -otex.v; } //yflip
|
||||||
|
|
||||||
//if ((usehightile && hicfindsubst(globalpicnum, globalpal, hictinting[globalpal].f & HICTINT_ALWAYSUSEART)))
|
calc_and_apply_fog(fogshade(nwal->shade, nwal->pal), sec->visibility, get_floor_fogpal(sec));
|
||||||
calc_and_apply_fog(fogshade(nwal->shade, nwal->pal), sec->visibility, get_floor_fogpal(sec));
|
|
||||||
|
|
||||||
pow2xsplit = 1;
|
pow2xsplit = 1;
|
||||||
#ifdef YAX_ENABLE
|
#ifdef YAX_ENABLE
|
||||||
|
@ -3224,8 +3199,7 @@ static void polymost_drawalls(int32_t const bunch)
|
||||||
}
|
}
|
||||||
if (wal->cstat&256) { xtex.v = -xtex.v; ytex.v = -ytex.v; otex.v = -otex.v; } //yflip
|
if (wal->cstat&256) { xtex.v = -xtex.v; ytex.v = -ytex.v; otex.v = -otex.v; } //yflip
|
||||||
|
|
||||||
//if ((usehightile && hicfindsubst(globalpicnum, globalpal, hictinting[globalpal].f & HICTINT_ALWAYSUSEART)))
|
calc_and_apply_fog(fogshade(wal->shade, wal->pal), sec->visibility, get_floor_fogpal(sec));
|
||||||
calc_and_apply_fog(fogshade(wal->shade, wal->pal), sec->visibility, get_floor_fogpal(sec));
|
|
||||||
|
|
||||||
pow2xsplit = 1;
|
pow2xsplit = 1;
|
||||||
|
|
||||||
|
@ -3904,8 +3878,7 @@ static void polymost_drawmaskwallinternal(int32_t wallIndex)
|
||||||
drawpoly_alpha = 0.f;
|
drawpoly_alpha = 0.f;
|
||||||
drawpoly_blend = blend;
|
drawpoly_blend = blend;
|
||||||
|
|
||||||
//if ((usehightile && hicfindsubst(globalpicnum, globalpal, hictinting[globalpal].f & HICTINT_ALWAYSUSEART)))
|
calc_and_apply_fog(fogshade(wal->shade, wal->pal), sec->visibility, get_floor_fogpal(sec));
|
||||||
calc_and_apply_fog(fogshade(wal->shade, wal->pal), sec->visibility, get_floor_fogpal(sec));
|
|
||||||
|
|
||||||
float const csy[4] = { ((float)(cz[0] - globalposz)) * ryp0 + ghoriz,
|
float const csy[4] = { ((float)(cz[0] - globalposz)) * ryp0 + ghoriz,
|
||||||
((float)(cz[1] - globalposz)) * ryp0 + ghoriz,
|
((float)(cz[1] - globalposz)) * ryp0 + ghoriz,
|
||||||
|
@ -4215,9 +4188,7 @@ void polymost_drawsprite(int32_t snum)
|
||||||
|
|
||||||
sec = (usectorptr_t)§or[tspr->sectnum];
|
sec = (usectorptr_t)§or[tspr->sectnum];
|
||||||
|
|
||||||
//if ((usehightile && hicfindsubst(globalpicnum, globalpal, hictinting[globalpal].f & HICTINT_ALWAYSUSEART))
|
calc_and_apply_fog(fogshade(globalshade, globalpal), sec->visibility, get_floor_fogpal(sec));
|
||||||
//|| (usemodels && md_tilehasmodel(globalpicnum, globalpal) >= 0))
|
|
||||||
calc_and_apply_fog(fogshade(globalshade, globalpal), sec->visibility, get_floor_fogpal(sec));
|
|
||||||
|
|
||||||
while (!(spriteext[spritenum].flags & SPREXT_NOTMD))
|
while (!(spriteext[spritenum].flags & SPREXT_NOTMD))
|
||||||
{
|
{
|
||||||
|
|
|
@ -341,9 +341,6 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3
|
||||||
if (!tilestat)
|
if (!tilestat)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (tilestat == -2) // bad filename
|
|
||||||
hicclearsubst(dapicnum, dapalnum);
|
|
||||||
|
|
||||||
return (drawingskybox || hicprecaching) ? NULL : texcache_tryart(dapicnum, dapalnum, dashade, dameth);
|
return (drawingskybox || hicprecaching) ? NULL : texcache_tryart(dapicnum, dapalnum, dashade, dameth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,10 +363,6 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3
|
||||||
texcache.list[j] = pth;
|
texcache.list[j] = pth;
|
||||||
return pth;
|
return pth;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tilestat == -2) // bad filename
|
|
||||||
hicclearsubst(dapicnum, dapalnum);
|
|
||||||
|
|
||||||
Xfree(pth);
|
Xfree(pth);
|
||||||
|
|
||||||
return (drawingskybox || hicprecaching) ? NULL : texcache_tryart(dapicnum, dapalnum, dashade, dameth);
|
return (drawingskybox || hicprecaching) ? NULL : texcache_tryart(dapicnum, dapalnum, dashade, dameth);
|
||||||
|
|
|
@ -439,7 +439,7 @@ int tileImportFromTexture(const char* fn, int tilenum, int alphacut, int istextu
|
||||||
//#if 0
|
//#if 0
|
||||||
// Does this make any difference when the texture gets *properly* inserted into the tile array?
|
// Does this make any difference when the texture gets *properly* inserted into the tile array?
|
||||||
//if (istexture)
|
//if (istexture)
|
||||||
hicsetsubsttex(tilenum, 0, fn, (float)(255 - alphacut) * (1.f / 255.f), 1.0f, 1.0f, 1.0, 1.0, 0); // At the moment this is the only way to load the texture. The texture creation code is not ready yet for downconverting an image.
|
tileSetHightileReplacement(tilenum, 0, fn, (float)(255 - alphacut) * (1.f / 255.f), 1.0f, 1.0f, 1.0, 1.0, 0); // At the moment this is the only way to load the texture. The texture creation code is not ready yet for downconverting an image.
|
||||||
//#endif
|
//#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -538,9 +538,20 @@ void tileDelete(int tile)
|
||||||
TileFiles.tiles[tile] = TileFiles.tilesbak[tile] = TileFiles.Placeholder;
|
TileFiles.tiles[tile] = TileFiles.tilesbak[tile] = TileFiles.Placeholder;
|
||||||
vox_undefine(tile);
|
vox_undefine(tile);
|
||||||
md_undefinetile(tile);
|
md_undefinetile(tile);
|
||||||
for (ssize_t i = MAXPALOOKUPS - 1; i >= 0; --i)
|
tileRemoveReplacement(tile);
|
||||||
hicclearsubst(tile, i);
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void tileRemoveReplacement(int tile)
|
||||||
|
{
|
||||||
|
if ((unsigned)tileNum >= MAXTILES) return false;
|
||||||
|
FTexture *tex = TileFiles.tiles[tile];
|
||||||
|
tex->DeleteReplacements();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -674,6 +685,92 @@ void BuildFiles::CloseAll()
|
||||||
Placeholder = nullptr;
|
Placeholder = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// Specifies a replacement texture for an ART tile.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
int tileSetHightileReplacement(int picnum, int palnum, const char *filename, float alphacut, float xscale, float yscale, float specpower, float specfactor, uint8_t flags)
|
||||||
|
{
|
||||||
|
if ((uint32_t)picnum >= (uint32_t)MAXTILES) return -1;
|
||||||
|
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return -1;
|
||||||
|
|
||||||
|
auto tex = TileFiles.tiles[picnum];
|
||||||
|
if (tex->GetWidth() <= 0 || tex->GetHeight() <= 0)
|
||||||
|
{
|
||||||
|
initprintf("Warning: defined hightile replacement for empty tile %d.", picnum);
|
||||||
|
return -1; // cannot add replacements to empty tiles, must create one beforehand
|
||||||
|
}
|
||||||
|
HightileReplacement replace = {};
|
||||||
|
|
||||||
|
replace.faces[0] = TileFiles.GetTexture(filename);
|
||||||
|
if (replace.faces[0] == nullptr)
|
||||||
|
{
|
||||||
|
initprintf("%s: Replacement for tile %d does not exist or is invalid\n", filename, picnum);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
replace.alphacut = min(alphacut,1.f);
|
||||||
|
replace.scale = { xscale, yscale };
|
||||||
|
replace.specpower = specpower; // currently unused
|
||||||
|
replace.specfactor = specfactor; // currently unused
|
||||||
|
replace.flags = flags;
|
||||||
|
replace.palnum = (uint8_t)palnum;
|
||||||
|
tex->AddReplacement(replace);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// Define the faces of a skybox
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
int tileSetSkybox(int picnum, int palnum, const char **facenames, int flags )
|
||||||
|
{
|
||||||
|
if ((uint32_t)picnum >= (uint32_t)MAXTILES) return -1;
|
||||||
|
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return -1;
|
||||||
|
|
||||||
|
if (tex->GetWidth() <= 0 || tex->GetHeight() <= 0)
|
||||||
|
{
|
||||||
|
initprintf("Warning: defined skybox replacement for empty tile %d.", picnum);
|
||||||
|
return -1; // cannot add replacements to empty tiles, must create one beforehand
|
||||||
|
}
|
||||||
|
HightileReplacement replace = {};
|
||||||
|
|
||||||
|
for (auto &face : replace.faces)
|
||||||
|
{
|
||||||
|
face = TileFiles.GetTexture(*facenames);
|
||||||
|
if (face == nullptr)
|
||||||
|
{
|
||||||
|
initprintf("%s: Skybox image for tile %d does not exist or is invalid\n", *facenames, picnum);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
replace.flags = flags;
|
||||||
|
replace.palnum = (uint8_t)palnum;
|
||||||
|
tex->AddReplacement(replace);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// Remove a replacement
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
int tileDeleteReplacement(int picnum, int palnum)
|
||||||
|
{
|
||||||
|
if ((uint32_t)picnum >= (uint32_t)MAXTILES) return -1;
|
||||||
|
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return -1;
|
||||||
|
auto tex = TileFiles.tiles[picnum];
|
||||||
|
tex->DeleteReplacement(palnum);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TileSiz tilesiz;
|
TileSiz tilesiz;
|
||||||
PicAnm picanm;
|
PicAnm picanm;
|
||||||
|
|
|
@ -400,6 +400,53 @@ void FTexture::Create8BitPixels(uint8_t *buffer)
|
||||||
// The base class does not fill the texture.
|
// The base class does not fill the texture.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// Replacement textures
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
void FTexture::AddReplacement(const HightileReplacement & replace)
|
||||||
|
{
|
||||||
|
for (auto &ht : Hightiles)
|
||||||
|
{
|
||||||
|
if (replace.palnum == ht.palnum && (replace.faces[1] == nullptr) == (ht.faces[1] == nullptr))
|
||||||
|
{
|
||||||
|
ht = replace;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Hightiles.Push(replace);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FTexture::DeleteReplacement(int palnum)
|
||||||
|
{
|
||||||
|
for (int i = Hightiles.Size() -1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (Hightiles[i].palnum == palnum) Hightiles.Delete(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
HightileReplacement *FTexture::FindReplacement(int palnum, int nozero, bool skybox)
|
||||||
|
{
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
for (auto &rep : Hightiles)
|
||||||
|
{
|
||||||
|
if (rep.palnum == palnum && (rep.faces[1] != nullptr) == skybox) return &rep;
|
||||||
|
}
|
||||||
|
if (!palnum || nozero) break;
|
||||||
|
palnum = 0;
|
||||||
|
}
|
||||||
|
return nullptr; // no replacement found
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
|
|
|
@ -100,6 +100,13 @@ struct rottile_t
|
||||||
int16_t owner;
|
int16_t owner;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct HightileReplacement
|
||||||
|
{
|
||||||
|
FTexture *faces[6]; // only one gets used by a texture, the other 5 are for skyboxes only
|
||||||
|
vec2f_t scale;
|
||||||
|
float alphacut, specpower, specfactor;
|
||||||
|
uint8_t palnum, flags;
|
||||||
|
};
|
||||||
|
|
||||||
class FBitmap;
|
class FBitmap;
|
||||||
struct FRemapTable;
|
struct FRemapTable;
|
||||||
|
@ -234,7 +241,15 @@ public:
|
||||||
bool ProcessData(unsigned char * buffer, int w, int h, bool ispatch);
|
bool ProcessData(unsigned char * buffer, int w, int h, bool ispatch);
|
||||||
virtual void Reload() {}
|
virtual void Reload() {}
|
||||||
UseType GetUseType() const { return useType; }
|
UseType GetUseType() const { return useType; }
|
||||||
|
void AddReplacement(const HightileReplacement &);
|
||||||
|
void DeleteReplacement(int palnum);
|
||||||
|
void DeleteReplacements()
|
||||||
|
{
|
||||||
|
Hightiles.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
HightileReplacement * FindReplacement(int palnum, int nozero = 0, bool skybox = false);
|
||||||
|
|
||||||
int alphaThreshold = 128;
|
int alphaThreshold = 128;
|
||||||
picanm_t PicAnim = {};
|
picanm_t PicAnim = {};
|
||||||
|
|
||||||
|
@ -282,6 +297,7 @@ protected:
|
||||||
PalEntry CeilingSkyColor;
|
PalEntry CeilingSkyColor;
|
||||||
intptr_t CacheHandle = 0; // For tiles that do not have a static image but get accessed by the software renderer.
|
intptr_t CacheHandle = 0; // For tiles that do not have a static image but get accessed by the software renderer.
|
||||||
uint8_t CacheLock = 0;
|
uint8_t CacheLock = 0;
|
||||||
|
TArray<HightileReplacement> Hightiles;
|
||||||
|
|
||||||
FTexture (const char *name = NULL);
|
FTexture (const char *name = NULL);
|
||||||
};
|
};
|
||||||
|
@ -525,10 +541,14 @@ int tileImportFromTexture(const char* fn, int tilenum, int alphacut, int istextu
|
||||||
void tileCopy(int tile, int tempsource, int temppal, int xoffset, int yoffset, int flags);
|
void tileCopy(int tile, int tempsource, int temppal, int xoffset, int yoffset, int flags);
|
||||||
void tileSetDummy(int tile, int width, int height);
|
void tileSetDummy(int tile, int width, int height);
|
||||||
void tileDelete(int tile);
|
void tileDelete(int tile);
|
||||||
|
void tileRemoveReplacement(int tile);
|
||||||
bool tileLoad(int tileNum);
|
bool tileLoad(int tileNum);
|
||||||
void artClearMapArt(void);
|
void artClearMapArt(void);
|
||||||
void artSetupMapArt(const char* filename);
|
void artSetupMapArt(const char* filename);
|
||||||
void tileSetAnim(int tile, const picanm_t& anm);
|
void tileSetAnim(int tile, const picanm_t& anm);
|
||||||
|
int tileSetHightileReplacement(int picnum, int palnum, const char *filen, float alphacut, float xscale, float yscale, float specpower, float specfactor, uint8_t flags);
|
||||||
|
int tileSetSkybox(int picnum, int palnum, const char **facenames, int flags );
|
||||||
|
int tileDeleteReplacement(int picnum, int palnum);
|
||||||
|
|
||||||
extern BuildFiles TileFiles;
|
extern BuildFiles TileFiles;
|
||||||
inline bool tileCheck(int num)
|
inline bool tileCheck(int num)
|
||||||
|
|
Loading…
Reference in a new issue