mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 03:00:38 +00:00
Large batch of Polymost changes, including:
-lots of stylistic rewrites -further improvements to anti-fighting code for wall and floor sprites (introduces three new cvars, r_wspr_offset, r_wspr_offset_variance, and r_fspr_offset) -fixed brief HOM when traversing through a one-way masked wall -seldomly used "alphahack" feature for hightile textures now represents alpha cutoff internally as a single byte instead of a float -fixes a handful of issues where geometry failed to draw at certain coordinates from certain angles in certain resolutions -renames a couple of cvars git-svn-id: https://svn.eduke32.com/eduke32@5075 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
93d8d2dbdb
commit
aa4d98982c
7 changed files with 2070 additions and 1937 deletions
|
@ -559,6 +559,16 @@ CLAMP_DECL float fclamp2(float in, float min, float max) { return in >= max ? ma
|
||||||
|
|
||||||
#define BMAX_PATH 256
|
#define BMAX_PATH 256
|
||||||
|
|
||||||
|
/* Static assertions, based on source found in LuaJIT's src/lj_def.h. */
|
||||||
|
#define EDUKE32_ASSERT_NAME2(name, line) name ## line
|
||||||
|
#define EDUKE32_ASSERT_NAME(line) EDUKE32_ASSERT_NAME2(eduke32_assert_, line)
|
||||||
|
#ifdef __COUNTER__
|
||||||
|
# define EDUKE32_STATIC_ASSERT(cond) \
|
||||||
|
extern void EDUKE32_ASSERT_NAME(__COUNTER__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1])
|
||||||
|
#else
|
||||||
|
# define EDUKE32_STATIC_ASSERT(cond) \
|
||||||
|
extern void EDUKE32_ASSERT_NAME(__LINE__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1])
|
||||||
|
#endif
|
||||||
|
|
||||||
struct Bdirent
|
struct Bdirent
|
||||||
{
|
{
|
||||||
|
@ -602,9 +612,20 @@ typedef struct {
|
||||||
} vec2f_t;
|
} vec2f_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float x, y, z;
|
union { float x; float d; };
|
||||||
|
union { float y; float u; };
|
||||||
|
union { float z; float v; };
|
||||||
} vec3f_t;
|
} vec3f_t;
|
||||||
|
|
||||||
|
EDUKE32_STATIC_ASSERT(sizeof(vec3f_t) == sizeof(float) * 3);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
union { double x; double d; };
|
||||||
|
union { double y; double u; };
|
||||||
|
union { double z; double v; };
|
||||||
|
} vec3d_t;
|
||||||
|
|
||||||
|
EDUKE32_STATIC_ASSERT(sizeof(vec3d_t) == sizeof(double) * 3);
|
||||||
|
|
||||||
#if RAND_MAX == 32767
|
#if RAND_MAX == 32767
|
||||||
FORCE_INLINE uint16_t system_15bit_rand(void) { return (uint16_t)rand(); }
|
FORCE_INLINE uint16_t system_15bit_rand(void) { return (uint16_t)rand(); }
|
||||||
|
@ -892,17 +913,6 @@ FORCE_INLINE void *xaligned_malloc(const bsize_t alignment, const bsize_t size)
|
||||||
if (fileptr) { Bfclose(fileptr); fileptr=NULL; } \
|
if (fileptr) { Bfclose(fileptr); fileptr=NULL; } \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* Static assertions, based on source found in LuaJIT's src/lj_def.h. */
|
|
||||||
#define EDUKE32_ASSERT_NAME2(name, line) name ## line
|
|
||||||
#define EDUKE32_ASSERT_NAME(line) EDUKE32_ASSERT_NAME2(eduke32_assert_, line)
|
|
||||||
#ifdef __COUNTER__
|
|
||||||
# define EDUKE32_STATIC_ASSERT(cond) \
|
|
||||||
extern void EDUKE32_ASSERT_NAME(__COUNTER__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1])
|
|
||||||
#else
|
|
||||||
# define EDUKE32_STATIC_ASSERT(cond) \
|
|
||||||
extern void EDUKE32_ASSERT_NAME(__LINE__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1])
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ARRAY_SIZE(Ar) (sizeof(Ar)/sizeof((Ar)[0]))
|
#define ARRAY_SIZE(Ar) (sizeof(Ar)/sizeof((Ar)[0]))
|
||||||
#define ARRAY_SSIZE(Ar) (bssize_t)ARRAY_SIZE(Ar)
|
#define ARRAY_SSIZE(Ar) (bssize_t)ARRAY_SIZE(Ar)
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct glfiltermodes {
|
||||||
extern struct glfiltermodes glfiltermodes[NUMGLFILTERMODES];
|
extern struct glfiltermodes glfiltermodes[NUMGLFILTERMODES];
|
||||||
|
|
||||||
//void phex(char v, char *s);
|
//void phex(char v, char *s);
|
||||||
void uploadtexture(int32_t doalloc, int32_t xsiz, int32_t ysiz, int32_t intexfmt, int32_t texfmt, coltype *pic, int32_t tsizx, int32_t tsizy, int32_t dameth);
|
void uploadtexture(int32_t doalloc, vec2_t siz, int32_t intexfmt, int32_t texfmt, coltype *pic, vec2_t tsiz, int32_t dameth);
|
||||||
void polymost_drawsprite(int32_t snum);
|
void polymost_drawsprite(int32_t snum);
|
||||||
void polymost_drawmaskwall(int32_t damaskwallcnt);
|
void polymost_drawmaskwall(int32_t damaskwallcnt);
|
||||||
void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
|
void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
|
||||||
|
@ -53,7 +53,7 @@ extern float curpolygonoffset;
|
||||||
|
|
||||||
extern float shadescale;
|
extern float shadescale;
|
||||||
extern int32_t shadescale_unbounded;
|
extern int32_t shadescale_unbounded;
|
||||||
extern float alphahackarray[MAXTILES];
|
extern uint8_t alphahackarray[MAXTILES];
|
||||||
|
|
||||||
extern int32_t r_usenewshading;
|
extern int32_t r_usenewshading;
|
||||||
extern int32_t r_usetileshades;
|
extern int32_t r_usetileshades;
|
||||||
|
@ -63,16 +63,16 @@ extern int16_t globalpicnum;
|
||||||
extern int32_t globalpal;
|
extern int32_t globalpal;
|
||||||
|
|
||||||
// Compare with polymer_eligible_for_artmap()
|
// Compare with polymer_eligible_for_artmap()
|
||||||
static inline int32_t eligible_for_tileshades(int32_t picnum, int32_t pal)
|
static inline int32_t eligible_for_tileshades(int32_t const picnum, int32_t const pal)
|
||||||
{
|
{
|
||||||
return (!usehightile || !hicfindsubst(picnum, pal)) &&
|
return (!usehightile || !hicfindsubst(picnum, pal)) &&
|
||||||
(!usemodels || md_tilehasmodel(picnum, pal) < 0);
|
(!usemodels || md_tilehasmodel(picnum, pal) < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline float getshadefactor(int32_t shade)
|
static inline float getshadefactor(int32_t const shade)
|
||||||
{
|
{
|
||||||
int32_t shadebound = (shadescale_unbounded || shade>=numshades) ? numshades : numshades-1;
|
int32_t const shadebound = (shadescale_unbounded || shade>=numshades) ? numshades : numshades-1;
|
||||||
float clamped_shade = min(max(shade*shadescale, 0), shadebound);
|
float const clamped_shade = min(max(shade*shadescale, 0), shadebound);
|
||||||
|
|
||||||
// 8-bit tiles, i.e. non-hightiles and non-models, don't get additional
|
// 8-bit tiles, i.e. non-hightiles and non-models, don't get additional
|
||||||
// glColor() shading with r_usetileshades!
|
// glColor() shading with r_usetileshades!
|
||||||
|
@ -86,22 +86,22 @@ static inline float getshadefactor(int32_t shade)
|
||||||
|
|
||||||
#define POLYMOST_CHOOSE_FOG_PAL(fogpal, pal) \
|
#define POLYMOST_CHOOSE_FOG_PAL(fogpal, pal) \
|
||||||
((fogpal) ? (fogpal) : (pal))
|
((fogpal) ? (fogpal) : (pal))
|
||||||
static inline int32_t get_floor_fogpal(const sectortype *sec)
|
static inline int32_t get_floor_fogpal(tsectortype const * const sec)
|
||||||
{
|
{
|
||||||
return POLYMOST_CHOOSE_FOG_PAL(sec->fogpal, sec->floorpal);
|
return POLYMOST_CHOOSE_FOG_PAL(sec->fogpal, sec->floorpal);
|
||||||
}
|
}
|
||||||
static inline int32_t get_ceiling_fogpal(const sectortype *sec)
|
static inline int32_t get_ceiling_fogpal(tsectortype const * const sec)
|
||||||
{
|
{
|
||||||
return POLYMOST_CHOOSE_FOG_PAL(sec->fogpal, sec->ceilingpal);
|
return POLYMOST_CHOOSE_FOG_PAL(sec->fogpal, sec->ceilingpal);
|
||||||
}
|
}
|
||||||
static inline int32_t fogpal_shade(const sectortype *sec, int32_t shade)
|
static inline int32_t fogpal_shade(tsectortype const * const sec, int32_t const shade)
|
||||||
{
|
{
|
||||||
// When fogging is due to sector[].fogpal, don't make the fog parameters
|
// When fogging is due to sector[].fogpal, don't make the fog parameters
|
||||||
// depend on the shade of the object.
|
// depend on the shade of the object.
|
||||||
return sec->fogpal ? 0 : shade;
|
return sec->fogpal ? 0 : shade;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int check_nonpow2(int32_t x)
|
static inline int check_nonpow2(int32_t const x)
|
||||||
{
|
{
|
||||||
return (x > 1 && (x&(x-1)));
|
return (x > 1 && (x&(x-1)));
|
||||||
}
|
}
|
||||||
|
@ -123,16 +123,16 @@ static inline int polymost_is_npotmode(void)
|
||||||
r_npotwallmode;
|
r_npotwallmode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline float polymost_invsqrt(float x)
|
static inline float polymost_invsqrt_approximation(float x)
|
||||||
{
|
{
|
||||||
#ifdef B_LITTLE_ENDIAN
|
#ifdef B_LITTLE_ENDIAN
|
||||||
const float haf = x*.5f;
|
float const haf = x * .5f;
|
||||||
struct conv { union { uint32_t i; float f; } u; } * const n = (struct conv *)&x;
|
struct conv { union { uint32_t i; float f; } u; } * const n = (struct conv *)&x;
|
||||||
n->u.i = 0x5f3759df-(n->u.i>>1);
|
n->u.i = 0x5f3759df - (n->u.i >> 1);
|
||||||
return n->u.f*(1.5f-haf*(n->u.f*n->u.f));
|
return n->u.f * (1.5f - haf * (n->u.f * n->u.f));
|
||||||
#else
|
#else
|
||||||
// this is the comment
|
// this is the comment
|
||||||
return 1.f/Bsqrtf(x);
|
return 1.f / Bsqrtf(x);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +144,7 @@ enum {
|
||||||
|
|
||||||
DAMETH_NOCOMPRESS = 4096,
|
DAMETH_NOCOMPRESS = 4096,
|
||||||
DAMETH_HI = 8192,
|
DAMETH_HI = 8192,
|
||||||
|
DAMETH_NOFIX = 16384,
|
||||||
};
|
};
|
||||||
|
|
||||||
// DAMETH_CLAMPED -> PTH_CLAMPED conversion
|
// DAMETH_CLAMPED -> PTH_CLAMPED conversion
|
||||||
|
|
|
@ -279,11 +279,6 @@ void fullscreen_tint_gl(uint8_t r, uint8_t g, uint8_t b, uint8_t f)
|
||||||
bglVertex2f(.0f, -2.5f);
|
bglVertex2f(.0f, -2.5f);
|
||||||
bglEnd();
|
bglEnd();
|
||||||
|
|
||||||
bglEnable(GL_DEPTH_TEST);
|
|
||||||
bglEnable(GL_ALPHA_TEST);
|
|
||||||
bglEnable(GL_TEXTURE_2D);
|
|
||||||
if (!nofog) bglEnable(GL_FOG);
|
|
||||||
|
|
||||||
bglPopMatrix();
|
bglPopMatrix();
|
||||||
bglMatrixMode(GL_PROJECTION);
|
bglMatrixMode(GL_PROJECTION);
|
||||||
bglPopMatrix();
|
bglPopMatrix();
|
||||||
|
|
|
@ -102,7 +102,7 @@ static char *faketilebuffer = NULL;
|
||||||
static int32_t faketilebuffersiz = 0;
|
static int32_t faketilebuffersiz = 0;
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
extern float alphahackarray[MAXTILES];
|
extern uint8_t alphahackarray[MAXTILES];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char *skyfaces[6] =
|
static const char *skyfaces[6] =
|
||||||
|
@ -397,7 +397,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
if (scriptfile_getdouble(script,&alpha)) break;
|
if (scriptfile_getdouble(script,&alpha)) break;
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
if ((uint32_t)tile < MAXTILES)
|
if ((uint32_t)tile < MAXTILES)
|
||||||
alphahackarray[tile] = alpha;
|
alphahackarray[tile] = alpha * UINT8_MAX;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -418,7 +418,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
for (i=tilenume1; i<=tilenume2; i++)
|
for (i=tilenume1; i<=tilenume2; i++)
|
||||||
alphahackarray[i] = alpha;
|
alphahackarray[i] = alpha * UINT8_MAX;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -674,7 +674,7 @@ static inline int32_t hicfxmask(int32_t pal)
|
||||||
//Note: even though it says md2model, it works for both md2model&md3model
|
//Note: even though it says md2model, it works for both md2model&md3model
|
||||||
int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
|
int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
|
||||||
{
|
{
|
||||||
int32_t i, bpl, xsiz=0, ysiz=0, osizx, osizy, texfmt = GL_RGBA, intexfmt = GL_RGBA;
|
int32_t i, bpl, osizx, osizy, texfmt = GL_RGBA, intexfmt = GL_RGBA;
|
||||||
char *skinfile, hasalpha, fn[BMAX_PATH];
|
char *skinfile, hasalpha, fn[BMAX_PATH];
|
||||||
GLuint *texidx = NULL;
|
GLuint *texidx = NULL;
|
||||||
mdskinmap_t *sk, *skzero = NULL;
|
mdskinmap_t *sk, *skzero = NULL;
|
||||||
|
@ -683,6 +683,7 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
|
||||||
texcacheheader cachead;
|
texcacheheader cachead;
|
||||||
|
|
||||||
int32_t startticks, willprint=0;
|
int32_t startticks, willprint=0;
|
||||||
|
vec2_t siz = { 0, 0 };
|
||||||
|
|
||||||
if (m->mdnum == 2)
|
if (m->mdnum == 2)
|
||||||
surf = 0;
|
surf = 0;
|
||||||
|
@ -776,7 +777,7 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
|
||||||
|
|
||||||
gotcache = texcache_readtexheader(fn, picfillen, pal<<8, hicfxmask(pal), &cachead, 1);
|
gotcache = texcache_readtexheader(fn, picfillen, pal<<8, hicfxmask(pal), &cachead, 1);
|
||||||
|
|
||||||
if (gotcache && !texcache_loadskin(&cachead, &doalloc, texidx, &xsiz, &ysiz))
|
if (gotcache && !texcache_loadskin(&cachead, &doalloc, texidx, &siz.x, &siz.y))
|
||||||
{
|
{
|
||||||
osizx = cachead.xdim;
|
osizx = cachead.xdim;
|
||||||
osizy = cachead.ydim;
|
osizy = cachead.ydim;
|
||||||
|
@ -795,7 +796,7 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
|
||||||
if ((filh = kopen4load(fn, 0)) < 0)
|
if ((filh = kopen4load(fn, 0)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ret = daskinloader(filh,&fptr,&bpl,&xsiz,&ysiz,&osizx,&osizy,&hasalpha,pal,hicfxmask(pal));
|
ret = daskinloader(filh,&fptr,&bpl,&siz.x,&siz.y,&osizx,&osizy,&hasalpha,pal,hicfxmask(pal));
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
|
@ -827,17 +828,17 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
|
||||||
if (glinfo.bgra)
|
if (glinfo.bgra)
|
||||||
texfmt = GL_BGRA;
|
texfmt = GL_BGRA;
|
||||||
|
|
||||||
uploadtexture((doalloc&1), xsiz, ysiz, intexfmt, texfmt, (coltype *)fptr, xsiz, ysiz, DAMETH_HI);
|
uploadtexture((doalloc&1), siz, intexfmt, texfmt, (coltype *)fptr, siz, DAMETH_HI);
|
||||||
Bfree((void *)fptr);
|
Bfree((void *)fptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m->skinloaded)
|
if (!m->skinloaded)
|
||||||
{
|
{
|
||||||
if (xsiz != osizx || ysiz != osizy)
|
if (siz.x != osizx || siz.y != osizy)
|
||||||
{
|
{
|
||||||
float fx, fy;
|
float fx, fy;
|
||||||
fx = ((float)osizx)/((float)xsiz);
|
fx = ((float)osizx)/((float)siz.x);
|
||||||
fy = ((float)osizy)/((float)ysiz);
|
fy = ((float)osizy)/((float)siz.y);
|
||||||
if (m->mdnum == 2)
|
if (m->mdnum == 2)
|
||||||
{
|
{
|
||||||
int32_t *lptr;
|
int32_t *lptr;
|
||||||
|
@ -879,7 +880,7 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
|
||||||
if (glinfo.texcompr && glusetexcompr && glusetexcache)
|
if (glinfo.texcompr && glusetexcompr && glusetexcache)
|
||||||
if (!gotcache)
|
if (!gotcache)
|
||||||
{
|
{
|
||||||
const int32_t nonpow2 = check_nonpow2(xsiz) || check_nonpow2(ysiz);
|
const int32_t nonpow2 = check_nonpow2(siz.x) || check_nonpow2(siz.y);
|
||||||
|
|
||||||
// save off the compressed version
|
// save off the compressed version
|
||||||
cachead.quality = r_downsize;
|
cachead.quality = r_downsize;
|
||||||
|
@ -1560,7 +1561,7 @@ static inline void normalize(float *vec)
|
||||||
if ((norm = vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]) == 0.f)
|
if ((norm = vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]) == 0.f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
norm = polymost_invsqrt(norm);
|
norm = polymost_invsqrt_approximation(norm);
|
||||||
vec[0] *= norm;
|
vec[0] *= norm;
|
||||||
vec[1] *= norm;
|
vec[1] *= norm;
|
||||||
vec[2] *= norm;
|
vec[2] *= norm;
|
||||||
|
@ -2103,7 +2104,7 @@ static int32_t polymost_md3draw(md3model_t *m, const tspritetype *tspr)
|
||||||
// PLAG : default cutoff removed
|
// PLAG : default cutoff removed
|
||||||
float al = 0.0;
|
float al = 0.0;
|
||||||
if (alphahackarray[globalpicnum] != 0)
|
if (alphahackarray[globalpicnum] != 0)
|
||||||
al=alphahackarray[globalpicnum];
|
al=alphahackarray[globalpicnum] * (1.f/255.f);
|
||||||
bglEnable(GL_BLEND);
|
bglEnable(GL_BLEND);
|
||||||
bglEnable(GL_ALPHA_TEST);
|
bglEnable(GL_ALPHA_TEST);
|
||||||
bglAlphaFunc(GL_GREATER,al);
|
bglAlphaFunc(GL_GREATER,al);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -99,9 +99,6 @@ pthtyp *texcache_fetchmulti(pthtyp *pth, hicreplctyp *si, int32_t dapicnum, int3
|
||||||
// <dashade>: ignored if not in Polymost+r_usetileshades
|
// <dashade>: ignored if not in Polymost+r_usetileshades
|
||||||
pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int32_t dameth)
|
pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int32_t dameth)
|
||||||
{
|
{
|
||||||
int32_t tilestat;
|
|
||||||
pthtyp *pth;
|
|
||||||
|
|
||||||
const int32_t j = dapicnum & (GLTEXCACHEADSIZ - 1);
|
const int32_t j = dapicnum & (GLTEXCACHEADSIZ - 1);
|
||||||
hicreplctyp *si = usehightile ? hicfindsubst(dapicnum, dapalnum) : NULL;
|
hicreplctyp *si = usehightile ? hicfindsubst(dapicnum, dapalnum) : NULL;
|
||||||
|
|
||||||
|
@ -125,7 +122,7 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// load a replacement
|
// load a replacement
|
||||||
for (pth = texcache.list[j]; pth; pth = pth->next)
|
for (pthtyp *pth = texcache.list[j]; pth; pth = pth->next)
|
||||||
{
|
{
|
||||||
if (pth->picnum == dapicnum && pth->palnum == si->palnum &&
|
if (pth->picnum == dapicnum && pth->palnum == si->palnum &&
|
||||||
(si->palnum > 0 ? 1 : (pth->effects == hictinting[dapalnum].f)) &&
|
(si->palnum > 0 ? 1 : (pth->effects == hictinting[dapalnum].f)) &&
|
||||||
|
@ -137,7 +134,7 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3
|
||||||
{
|
{
|
||||||
pth->flags &= ~PTH_INVALIDATED;
|
pth->flags &= ~PTH_INVALIDATED;
|
||||||
|
|
||||||
tilestat = gloadtile_hi(dapicnum, dapalnum, drawingskybox, si, dameth, pth, 0,
|
int32_t tilestat = gloadtile_hi(dapicnum, dapalnum, drawingskybox, si, dameth, pth, 0,
|
||||||
(si->palnum > 0) ? 0 : hictinting[dapalnum].f); // reload tile
|
(si->palnum > 0) ? 0 : hictinting[dapalnum].f); // reload tile
|
||||||
|
|
||||||
if (!tilestat)
|
if (!tilestat)
|
||||||
|
@ -148,17 +145,17 @@ pthtyp *texcache_fetch(int32_t dapicnum, int32_t dapalnum, int32_t dashade, int3
|
||||||
return (drawingskybox || hicprecaching) ? NULL : texcache_tryart(dapicnum, dapalnum, dashade, dameth);
|
return (drawingskybox || hicprecaching) ? NULL : texcache_tryart(dapicnum, dapalnum, dashade, dameth);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (pth);
|
return pth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pth = (pthtyp *)Xcalloc(1, sizeof(pthtyp));
|
pthtyp *pth = (pthtyp *)Xcalloc(1, sizeof(pthtyp));
|
||||||
|
|
||||||
// possibly fetch an already loaded multitexture :_)
|
// possibly fetch an already loaded multitexture :_)
|
||||||
if (dapalnum >= (MAXPALOOKUPS - RESERVEDPALS) && texcache_fetchmulti(pth, si, dapicnum, dameth))
|
if (dapalnum >= (MAXPALOOKUPS - RESERVEDPALS) && texcache_fetchmulti(pth, si, dapicnum, dameth))
|
||||||
return pth;
|
return pth;
|
||||||
|
|
||||||
tilestat =
|
int32_t tilestat =
|
||||||
gloadtile_hi(dapicnum, dapalnum, drawingskybox, si, dameth, pth, 1, (si->palnum > 0) ? 0 : hictinting[dapalnum].f);
|
gloadtile_hi(dapicnum, dapalnum, drawingskybox, si, dameth, pth, 1, (si->palnum > 0) ? 0 : hictinting[dapalnum].f);
|
||||||
|
|
||||||
if (!tilestat)
|
if (!tilestat)
|
||||||
|
@ -531,13 +528,14 @@ void texcache_writetex(const char *fn, int32_t len, int32_t dameth, char effect,
|
||||||
char cachefn[BMAX_PATH];
|
char cachefn[BMAX_PATH];
|
||||||
char *pic = NULL, *packbuf = NULL;
|
char *pic = NULL, *packbuf = NULL;
|
||||||
void *midbuf = NULL;
|
void *midbuf = NULL;
|
||||||
uint32_t alloclen=0, level;
|
uint32_t alloclen=0, level=0;
|
||||||
uint32_t padx=0, pady=0;
|
uint32_t padx=0, pady=0;
|
||||||
GLint gi;
|
GLint gi;
|
||||||
int32_t offset = 0;
|
int32_t offset = 0;
|
||||||
|
|
||||||
if (!texcache_enabled()) return;
|
if (!texcache_enabled()) return;
|
||||||
|
|
||||||
|
#ifndef EDUKE32_GLES
|
||||||
gi = GL_FALSE;
|
gi = GL_FALSE;
|
||||||
bglGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_ARB, &gi);
|
bglGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_ARB, &gi);
|
||||||
if (gi != GL_TRUE)
|
if (gi != GL_TRUE)
|
||||||
|
@ -549,6 +547,7 @@ void texcache_writetex(const char *fn, int32_t len, int32_t dameth, char effect,
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Blseek(texcache.filehandle, 0, BSEEK_END);
|
Blseek(texcache.filehandle, 0, BSEEK_END);
|
||||||
|
|
||||||
|
@ -570,11 +569,14 @@ void texcache_writetex(const char *fn, int32_t len, int32_t dameth, char effect,
|
||||||
|
|
||||||
CLEAR_GL_ERRORS();
|
CLEAR_GL_ERRORS();
|
||||||
|
|
||||||
|
#ifndef EDUKE32_GLES
|
||||||
for (level = 0; level==0 || (padx > 1 || pady > 1); level++)
|
for (level = 0; level==0 || (padx > 1 || pady > 1); level++)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
uint32_t miplen;
|
uint32_t miplen;
|
||||||
texcachepicture pict;
|
texcachepicture pict;
|
||||||
|
|
||||||
|
#ifndef EDUKE32_GLES
|
||||||
bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_COMPRESSED_ARB, &gi); WRITEX_FAIL_ON_ERROR();
|
bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_COMPRESSED_ARB, &gi); WRITEX_FAIL_ON_ERROR();
|
||||||
if (gi != GL_TRUE) goto failure; // an uncompressed mipmap
|
if (gi != GL_TRUE) goto failure; // an uncompressed mipmap
|
||||||
bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_INTERNAL_FORMAT, &gi); WRITEX_FAIL_ON_ERROR();
|
bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_INTERNAL_FORMAT, &gi); WRITEX_FAIL_ON_ERROR();
|
||||||
|
@ -594,7 +596,13 @@ void texcache_writetex(const char *fn, int32_t len, int32_t dameth, char effect,
|
||||||
pict.depth = B_LITTLE32(gi);
|
pict.depth = B_LITTLE32(gi);
|
||||||
bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, &gi); WRITEX_FAIL_ON_ERROR();
|
bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, &gi); WRITEX_FAIL_ON_ERROR();
|
||||||
miplen = gi; pict.size = B_LITTLE32(gi);
|
miplen = gi; pict.size = B_LITTLE32(gi);
|
||||||
|
#else // TODO: actually code this ;)
|
||||||
|
// pict.format = GL_ETC1_RGB8_OES;
|
||||||
|
pict.xdim = head->xdim;
|
||||||
|
pict.ydim = head->ydim;
|
||||||
|
pict.border = 0;
|
||||||
|
pict.depth = 16;
|
||||||
|
#endif
|
||||||
if (alloclen < miplen)
|
if (alloclen < miplen)
|
||||||
{
|
{
|
||||||
pic = (char *)Xrealloc(pic, miplen);
|
pic = (char *)Xrealloc(pic, miplen);
|
||||||
|
@ -632,9 +640,9 @@ void texcache_writetex(const char *fn, int32_t len, int32_t dameth, char effect,
|
||||||
if (++texcache.numentries > texcache.iptrcnt)
|
if (++texcache.numentries > texcache.iptrcnt)
|
||||||
{
|
{
|
||||||
texcache.iptrcnt += 512;
|
texcache.iptrcnt += 512;
|
||||||
texcache.iptrs = (texcacheindex **) Xrealloc(texcache.iptrs, sizeof(intptr_t) * texcache.iptrcnt);
|
texcache.iptrs = (texcacheindex **)Xrealloc(texcache.iptrs, sizeof(intptr_t) * texcache.iptrcnt);
|
||||||
}
|
}
|
||||||
texcache.iptrs[texcache.numentries-1] = t;
|
texcache.iptrs[texcache.numentries - 1] = t;
|
||||||
texcache.currentindex = t->next;
|
texcache.currentindex = t->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,7 +651,8 @@ void texcache_writetex(const char *fn, int32_t len, int32_t dameth, char effect,
|
||||||
fseek(texcache.index, 0, BSEEK_END);
|
fseek(texcache.index, 0, BSEEK_END);
|
||||||
Bfprintf(texcache.index, "%s %d %d\n", t->name, t->offset, t->len);
|
Bfprintf(texcache.index, "%s %d %d\n", t->name, t->offset, t->len);
|
||||||
}
|
}
|
||||||
else OSD_Printf("wtf?\n");
|
else
|
||||||
|
OSD_Printf("wtf?\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
goto success;
|
goto success;
|
||||||
|
@ -671,13 +680,15 @@ static void texcache_setuptexture(int32_t *doalloc, GLuint *glpic)
|
||||||
|
|
||||||
static int32_t texcache_loadmips(const texcacheheader *head, GLenum *glerr, int32_t *xsiz, int32_t *ysiz)
|
static int32_t texcache_loadmips(const texcacheheader *head, GLenum *glerr, int32_t *xsiz, int32_t *ysiz)
|
||||||
{
|
{
|
||||||
int32_t level;
|
int32_t level = 0;
|
||||||
texcachepicture pict;
|
texcachepicture pict;
|
||||||
char *pic = NULL, *packbuf = NULL;
|
char *pic = NULL, *packbuf = NULL;
|
||||||
void *midbuf = NULL;
|
void *midbuf = NULL;
|
||||||
int32_t alloclen=0;
|
int32_t alloclen=0;
|
||||||
|
|
||||||
|
#ifndef EDUKE32_GLES
|
||||||
for (level = 0; level==0 || (pict.xdim > 1 || pict.ydim > 1); level++)
|
for (level = 0; level==0 || (pict.xdim > 1 || pict.ydim > 1); level++)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
GLint format;
|
GLint format;
|
||||||
|
|
||||||
|
@ -723,6 +734,7 @@ static int32_t texcache_loadmips(const texcacheheader *head, GLenum *glerr, int3
|
||||||
return TEXCACHERR_COMPTEX;
|
return TEXCACHERR_COMPTEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef EDUKE32_GLES
|
||||||
bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_INTERNAL_FORMAT, &format);
|
bglGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_INTERNAL_FORMAT, &format);
|
||||||
if ((*glerr = bglGetError()) != GL_NO_ERROR)
|
if ((*glerr = bglGetError()) != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
|
@ -736,6 +748,7 @@ static int32_t texcache_loadmips(const texcacheheader *head, GLenum *glerr, int3
|
||||||
TEXCACHE_FREEBUFS();
|
TEXCACHE_FREEBUFS();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TEXCACHE_FREEBUFS();
|
TEXCACHE_FREEBUFS();
|
||||||
|
|
Loading…
Reference in a new issue