2014-11-22 12:32:56 +00:00
|
|
|
#ifndef polymost_h_
|
|
|
|
# define polymost_h_
|
2006-08-30 23:32:39 +00:00
|
|
|
|
|
|
|
|
2018-11-18 18:09:48 +00:00
|
|
|
#include "baselayer.h" // glinfo
|
2009-08-09 05:32:17 +00:00
|
|
|
#include "hightile.h"
|
2019-09-19 20:02:45 +00:00
|
|
|
#include "mdsprite.h"
|
2009-08-09 05:32:17 +00:00
|
|
|
|
2019-09-13 20:18:37 +00:00
|
|
|
void Polymost_CacheHitList(uint8_t* hash);
|
|
|
|
|
2019-09-18 18:44:21 +00:00
|
|
|
class FHardwareTexture;
|
2014-09-30 04:17:37 +00:00
|
|
|
typedef struct { uint8_t r, g, b, a; } coltype;
|
2015-03-24 00:40:48 +00:00
|
|
|
typedef struct { float r, g, b, a; } coltypef;
|
2008-12-02 10:44:39 +00:00
|
|
|
|
2019-09-18 22:19:02 +00:00
|
|
|
extern bool playing_rr;
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t rendmode;
|
2008-12-02 10:44:39 +00:00
|
|
|
extern float gtang;
|
|
|
|
extern float glox1, gloy1;
|
2019-03-19 17:08:05 +00:00
|
|
|
extern double gxyaspect;
|
|
|
|
extern float grhalfxdown10x;
|
2014-09-30 04:06:05 +00:00
|
|
|
extern float gcosang, gsinang, gcosang2, gsinang2;
|
|
|
|
extern float gchang, gshang, gctang, gstang, gvisibility;
|
2019-08-07 22:44:33 +00:00
|
|
|
extern float gvrcorrection;
|
2008-12-02 10:44:39 +00:00
|
|
|
|
|
|
|
struct glfiltermodes {
|
2018-10-07 05:20:52 +00:00
|
|
|
const char *name;
|
2006-08-30 23:32:39 +00:00
|
|
|
};
|
2012-10-01 17:52:25 +00:00
|
|
|
#define NUMGLFILTERMODES 6
|
|
|
|
extern struct glfiltermodes glfiltermodes[NUMGLFILTERMODES];
|
2008-12-02 10:44:39 +00:00
|
|
|
|
2016-10-24 21:30:34 +00:00
|
|
|
extern void Polymost_prepare_loadboard(void);
|
|
|
|
|
2019-05-25 14:59:09 +00:00
|
|
|
void polymost_outputGLDebugMessage(uint8_t severity, const char* format, ...);
|
2019-09-13 20:18:37 +00:00
|
|
|
|
2012-01-12 20:47:41 +00:00
|
|
|
//void phex(char v, char *s);
|
2019-09-18 18:44:21 +00:00
|
|
|
void uploadtexture(FHardwareTexture *tex, int32_t doalloc, vec2_t siz, int32_t texfmt, coltype *pic, vec2_t tsiz, int32_t dameth);
|
2019-10-06 17:32:35 +00:00
|
|
|
void uploadbasepalette(int32_t basepalnum, bool transient = false);
|
2019-10-06 17:47:31 +00:00
|
|
|
void uploadpalswaps(int count, int32_t *palookupnum);
|
2009-01-09 09:29:17 +00:00
|
|
|
void polymost_drawsprite(int32_t snum);
|
|
|
|
void polymost_drawmaskwall(int32_t damaskwallcnt);
|
|
|
|
void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
|
2019-09-22 21:15:46 +00:00
|
|
|
int8_t dashade, uint8_t dapalnum, int32_t dastat, uint8_t daalpha, uint8_t dablend, int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2, int32_t uniqid);
|
2009-01-09 09:29:17 +00:00
|
|
|
void polymost_fillpolygon(int32_t npoints);
|
2008-12-02 10:44:39 +00:00
|
|
|
void polymost_initosdfuncs(void);
|
|
|
|
void polymost_drawrooms(void);
|
2019-06-25 18:35:16 +00:00
|
|
|
void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fix16_t daang, fix16_t dahoriz, int16_t mirrorWall);
|
|
|
|
void polymost_completeMirror();
|
2008-12-02 10:44:39 +00:00
|
|
|
|
2019-04-19 21:45:22 +00:00
|
|
|
int32_t polymost_maskWallHasTranslucency(uwalltype const * const wall);
|
|
|
|
int32_t polymost_spriteHasTranslucency(uspritetype const * const tspr);
|
|
|
|
|
2019-08-07 22:44:33 +00:00
|
|
|
float* multiplyMatrix4f(float m0[4*4], const float m1[4*4]);
|
|
|
|
|
2008-12-02 10:44:39 +00:00
|
|
|
void polymost_glinit(void);
|
|
|
|
void polymost_glreset(void);
|
|
|
|
|
2013-05-15 02:20:08 +00:00
|
|
|
enum {
|
|
|
|
INVALIDATE_ALL,
|
2018-03-21 20:41:26 +00:00
|
|
|
INVALIDATE_ART,
|
|
|
|
INVALIDATE_ALL_NON_INDEXED,
|
|
|
|
INVALIDATE_ART_NON_INDEXED
|
2013-05-15 02:20:08 +00:00
|
|
|
};
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void gltexinvalidate(int32_t dapicnum, int32_t dapalnum, int32_t dameth);
|
2013-05-15 02:20:08 +00:00
|
|
|
void gltexinvalidatetype(int32_t type);
|
2010-05-18 05:14:17 +00:00
|
|
|
int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, const char *name, char fontsize);
|
2008-12-02 10:44:39 +00:00
|
|
|
|
2009-02-02 01:49:14 +00:00
|
|
|
extern float curpolygonoffset;
|
|
|
|
|
2008-12-02 10:44:39 +00:00
|
|
|
extern float shadescale;
|
2011-03-17 23:37:38 +00:00
|
|
|
extern int32_t shadescale_unbounded;
|
2015-03-24 00:40:33 +00:00
|
|
|
extern uint8_t alphahackarray[MAXTILES];
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2011-07-24 15:15:57 +00:00
|
|
|
extern int32_t r_usenewshading;
|
2014-06-01 11:55:19 +00:00
|
|
|
extern int32_t r_npotwallmode;
|
2019-09-18 22:19:02 +00:00
|
|
|
extern int32_t r_brightnesshack;
|
2019-09-19 20:02:45 +00:00
|
|
|
extern int32_t polymostcenterhoriz;
|
2011-07-24 15:15:57 +00:00
|
|
|
|
2013-05-15 02:19:14 +00:00
|
|
|
extern int16_t globalpicnum;
|
|
|
|
|
2014-03-30 13:53:09 +00:00
|
|
|
// Compare with polymer_eligible_for_artmap()
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE int32_t eligible_for_tileshades(int32_t const picnum, int32_t const pal)
|
2014-03-30 13:53:08 +00:00
|
|
|
{
|
2017-06-21 13:46:59 +00:00
|
|
|
return !usehightile || !hicfindsubst(picnum, pal, hictinting[pal].f & HICTINT_ALWAYSUSEART);
|
2014-03-30 13:53:08 +00:00
|
|
|
}
|
|
|
|
|
2015-03-24 00:40:33 +00:00
|
|
|
static inline float getshadefactor(int32_t const shade)
|
2012-12-14 19:28:01 +00:00
|
|
|
{
|
2014-03-25 21:04:33 +00:00
|
|
|
// 8-bit tiles, i.e. non-hightiles and non-models, don't get additional
|
2019-10-05 11:38:02 +00:00
|
|
|
// shading with r_usetileshades!
|
2019-03-19 17:09:12 +00:00
|
|
|
if (videoGetRenderMode() == REND_POLYMOST && !(globalflags & GLOBAL_NO_GL_TILESHADES) && eligible_for_tileshades(globalpicnum, globalpal))
|
2014-03-25 21:04:33 +00:00
|
|
|
return 1.f;
|
|
|
|
|
2017-11-29 07:29:33 +00:00
|
|
|
if (r_usenewshading == 4)
|
2017-12-12 05:14:12 +00:00
|
|
|
return max(min(1.f - (shade * shadescale / frealmaxshade), 1.f), 0.f);
|
2017-11-29 07:29:33 +00:00
|
|
|
|
2015-11-25 12:07:47 +00:00
|
|
|
float const shadebound = (float)((shadescale_unbounded || shade>=numshades) ? numshades : numshades-1);
|
|
|
|
float const scaled_shade = (float)shade*shadescale;
|
|
|
|
float const clamped_shade = min(max(scaled_shade, 0.f), shadebound);
|
|
|
|
|
2012-12-14 19:28:01 +00:00
|
|
|
return ((float)(numshades-clamped_shade))/(float)numshades;
|
|
|
|
}
|
|
|
|
|
2014-04-05 11:28:10 +00:00
|
|
|
#define POLYMOST_CHOOSE_FOG_PAL(fogpal, pal) \
|
|
|
|
((fogpal) ? (fogpal) : (pal))
|
2019-04-18 17:25:24 +00:00
|
|
|
static FORCE_INLINE int32_t get_floor_fogpal(usectorptr_t const sec)
|
2014-04-05 11:28:08 +00:00
|
|
|
{
|
2014-04-05 11:28:10 +00:00
|
|
|
return POLYMOST_CHOOSE_FOG_PAL(sec->fogpal, sec->floorpal);
|
2014-04-05 11:28:08 +00:00
|
|
|
}
|
2019-04-18 17:25:24 +00:00
|
|
|
static FORCE_INLINE int32_t get_ceiling_fogpal(usectorptr_t const sec)
|
2014-04-05 11:28:08 +00:00
|
|
|
{
|
2014-04-05 11:28:10 +00:00
|
|
|
return POLYMOST_CHOOSE_FOG_PAL(sec->fogpal, sec->ceilingpal);
|
2014-04-05 11:28:08 +00:00
|
|
|
}
|
2017-12-12 05:14:06 +00:00
|
|
|
static FORCE_INLINE int32_t fogshade(int32_t const shade, int32_t const pal)
|
2014-05-01 22:02:21 +00:00
|
|
|
{
|
2017-12-12 05:14:06 +00:00
|
|
|
polytintflags_t const tintflags = hictinting[pal].f;
|
|
|
|
return (globalflags & GLOBAL_NO_GL_FOGSHADE || tintflags & HICTINT_NOFOGSHADE) ? 0 : shade;
|
2014-05-01 22:02:21 +00:00
|
|
|
}
|
2014-04-05 11:28:08 +00:00
|
|
|
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE int check_nonpow2(int32_t const x)
|
2014-05-28 22:40:19 +00:00
|
|
|
{
|
2014-06-01 11:55:19 +00:00
|
|
|
return (x > 1 && (x&(x-1)));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Are we using the mode that uploads non-power-of-two wall textures like they
|
|
|
|
// render in classic?
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE int polymost_is_npotmode(void)
|
2014-06-01 11:55:19 +00:00
|
|
|
{
|
|
|
|
// The glinfo.texnpot check is so we don't have to deal with that case in
|
|
|
|
// gloadtile_art().
|
2019-10-04 16:12:03 +00:00
|
|
|
return
|
2014-06-01 11:55:19 +00:00
|
|
|
// r_npotwallmode is NYI for hightiles. We require r_hightile off
|
|
|
|
// because in calc_ypanning(), the repeat would be multiplied by a
|
|
|
|
// factor even if no modified texture were loaded.
|
|
|
|
!usehightile &&
|
2019-10-04 16:12:03 +00:00
|
|
|
r_npotwallmode;
|
2014-05-28 22:40:19 +00:00
|
|
|
}
|
|
|
|
|
2015-03-24 00:40:33 +00:00
|
|
|
static inline float polymost_invsqrt_approximation(float x)
|
2014-09-30 04:17:37 +00:00
|
|
|
{
|
|
|
|
#ifdef B_LITTLE_ENDIAN
|
2015-03-24 00:40:33 +00:00
|
|
|
float const haf = x * .5f;
|
2019-04-20 21:57:05 +00:00
|
|
|
union { float f; uint32_t i; } n = { x };
|
|
|
|
n.i = 0x5f375a86 - (n.i >> 1);
|
|
|
|
return n.f * (1.5f - haf * (n.f * n.f));
|
2014-09-30 04:17:37 +00:00
|
|
|
#else
|
|
|
|
// this is the comment
|
2015-03-24 00:40:33 +00:00
|
|
|
return 1.f / Bsqrtf(x);
|
2014-09-30 04:17:37 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-05-28 22:40:16 +00:00
|
|
|
// Flags of the <dameth> argument of various functions
|
|
|
|
enum {
|
2015-12-04 11:52:54 +00:00
|
|
|
DAMETH_NOMASK = 0,
|
|
|
|
DAMETH_MASK = 1,
|
|
|
|
DAMETH_TRANS1 = 2,
|
|
|
|
DAMETH_TRANS2 = 3,
|
|
|
|
|
|
|
|
DAMETH_MASKPROPS = 3,
|
|
|
|
|
2014-05-28 22:40:16 +00:00
|
|
|
DAMETH_CLAMPED = 4,
|
|
|
|
|
2014-06-01 11:55:19 +00:00
|
|
|
DAMETH_WALL = 32, // signals a texture for a wall (for r_npotwallmode)
|
|
|
|
|
2015-12-04 11:52:54 +00:00
|
|
|
// used internally by polymost_domost
|
|
|
|
DAMETH_BACKFACECULL = -1,
|
|
|
|
|
|
|
|
// used internally by uploadtexture
|
2016-02-29 06:34:12 +00:00
|
|
|
DAMETH_NODOWNSIZE = 4096,
|
2014-05-28 22:40:16 +00:00
|
|
|
DAMETH_HI = 8192,
|
2015-03-24 00:40:33 +00:00
|
|
|
DAMETH_NOFIX = 16384,
|
2016-02-29 06:34:20 +00:00
|
|
|
DAMETH_NOTEXCOMPRESS = 32768,
|
|
|
|
DAMETH_HASALPHA = 65536,
|
|
|
|
DAMETH_ONEBITALPHA = 131072,
|
2016-03-07 11:21:55 +00:00
|
|
|
DAMETH_ARTIMMUNITY = 262144,
|
|
|
|
|
2016-05-04 00:25:17 +00:00
|
|
|
DAMETH_HASFULLBRIGHT = 524288,
|
|
|
|
DAMETH_NPOTWALL = 1048576,
|
|
|
|
|
2016-05-04 00:25:13 +00:00
|
|
|
DAMETH_UPLOADTEXTURE_MASK =
|
|
|
|
DAMETH_HI |
|
|
|
|
DAMETH_NODOWNSIZE |
|
|
|
|
DAMETH_NOFIX |
|
|
|
|
DAMETH_NOTEXCOMPRESS |
|
|
|
|
DAMETH_HASALPHA |
|
|
|
|
DAMETH_ONEBITALPHA |
|
2016-05-04 00:25:17 +00:00
|
|
|
DAMETH_ARTIMMUNITY |
|
|
|
|
DAMETH_HASFULLBRIGHT |
|
|
|
|
DAMETH_NPOTWALL,
|
2014-05-28 22:40:16 +00:00
|
|
|
};
|
|
|
|
|
2015-12-04 11:52:58 +00:00
|
|
|
#define DAMETH_NARROW_MASKPROPS(dameth) (((dameth)&(~DAMETH_TRANS1))|(((dameth)&DAMETH_TRANS1)>>1))
|
|
|
|
EDUKE32_STATIC_ASSERT(DAMETH_NARROW_MASKPROPS(DAMETH_MASKPROPS) == DAMETH_MASK);
|
|
|
|
EDUKE32_STATIC_ASSERT(DAMETH_NARROW_MASKPROPS(DAMETH_CLAMPED) == DAMETH_CLAMPED);
|
2014-05-28 22:40:16 +00:00
|
|
|
|
2016-02-29 06:34:20 +00:00
|
|
|
#define TO_DAMETH_NODOWNSIZE(hicr_flags) (((hicr_flags)&HICR_NODOWNSIZE)<<8)
|
|
|
|
EDUKE32_STATIC_ASSERT(TO_DAMETH_NODOWNSIZE(HICR_NODOWNSIZE) == DAMETH_NODOWNSIZE);
|
|
|
|
#define TO_DAMETH_NOTEXCOMPRESS(hicr_flags) (((hicr_flags)&HICR_NOTEXCOMPRESS)<<15)
|
|
|
|
EDUKE32_STATIC_ASSERT(TO_DAMETH_NOTEXCOMPRESS(HICR_NOTEXCOMPRESS) == DAMETH_NOTEXCOMPRESS);
|
2016-03-07 11:21:55 +00:00
|
|
|
#define TO_DAMETH_ARTIMMUNITY(hicr_flags) (((hicr_flags)&HICR_ARTIMMUNITY)<<13)
|
|
|
|
EDUKE32_STATIC_ASSERT(TO_DAMETH_ARTIMMUNITY(HICR_ARTIMMUNITY) == DAMETH_ARTIMMUNITY);
|
2016-02-29 06:34:20 +00:00
|
|
|
|
2014-06-01 11:55:19 +00:00
|
|
|
// Do we want a NPOT-y-as-classic texture for this <dameth> and <ysiz>?
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE int polymost_want_npotytex(int32_t dameth, int32_t ysiz)
|
2014-06-01 11:55:19 +00:00
|
|
|
{
|
2019-09-18 18:44:21 +00:00
|
|
|
return polymost_is_npotmode() && (dameth&DAMETH_WALL) && check_nonpow2(ysiz);
|
2014-06-01 11:55:19 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 22:40:16 +00:00
|
|
|
// pthtyp pth->flags bits
|
2015-12-04 11:52:58 +00:00
|
|
|
enum pthtyp_flags {
|
2014-05-28 22:40:16 +00:00
|
|
|
PTH_CLAMPED = 1,
|
|
|
|
PTH_HIGHTILE = 2,
|
|
|
|
PTH_SKYBOX = 4,
|
|
|
|
PTH_HASALPHA = 8,
|
|
|
|
PTH_HASFULLBRIGHT = 16,
|
2014-06-01 11:55:19 +00:00
|
|
|
PTH_NPOTWALL = DAMETH_WALL, // r_npotwallmode=1 generated texture
|
2015-03-28 09:49:37 +00:00
|
|
|
PTH_FORCEFILTER = 64,
|
2014-05-28 22:40:16 +00:00
|
|
|
|
|
|
|
PTH_INVALIDATED = 128,
|
2015-12-04 11:52:58 +00:00
|
|
|
|
|
|
|
PTH_NOTRANSFIX = 256, // fixtransparency() bypassed
|
2018-03-21 20:41:26 +00:00
|
|
|
|
|
|
|
PTH_INDEXED = 512,
|
2019-04-19 21:45:22 +00:00
|
|
|
PTH_ONEBITALPHA = 1024,
|
2014-05-28 22:40:16 +00:00
|
|
|
};
|
|
|
|
|
2006-08-30 23:32:39 +00:00
|
|
|
typedef struct pthtyp_t
|
|
|
|
{
|
|
|
|
struct pthtyp_t *next;
|
2014-09-30 04:17:37 +00:00
|
|
|
struct pthtyp_t *ofb; // fullbright pixels
|
|
|
|
hicreplctyp *hicr;
|
|
|
|
|
2019-09-18 18:44:21 +00:00
|
|
|
FHardwareTexture * glpic;
|
2014-09-30 04:17:37 +00:00
|
|
|
vec2f_t scale;
|
|
|
|
vec2_t siz;
|
|
|
|
int16_t picnum;
|
|
|
|
|
2015-12-04 11:52:58 +00:00
|
|
|
uint16_t flags; // see pthtyp_flags
|
2017-06-21 13:46:44 +00:00
|
|
|
polytintflags_t effects;
|
2014-09-30 04:17:37 +00:00
|
|
|
char palnum;
|
|
|
|
char shade;
|
|
|
|
char skyface;
|
2007-01-29 01:18:16 +00:00
|
|
|
} pthtyp;
|
|
|
|
|
2015-12-04 11:52:58 +00:00
|
|
|
// DAMETH -> PTH conversions
|
|
|
|
#define TO_PTH_CLAMPED(dameth) (((dameth)&DAMETH_CLAMPED)>>2)
|
|
|
|
EDUKE32_STATIC_ASSERT(TO_PTH_CLAMPED(DAMETH_CLAMPED) == PTH_CLAMPED);
|
|
|
|
#define TO_PTH_NOTRANSFIX(dameth) ((((~(dameth))&DAMETH_MASK)<<8)&(((~(dameth))&DAMETH_TRANS1)<<7))
|
|
|
|
EDUKE32_STATIC_ASSERT(TO_PTH_NOTRANSFIX(DAMETH_NOMASK) == PTH_NOTRANSFIX);
|
|
|
|
EDUKE32_STATIC_ASSERT(TO_PTH_NOTRANSFIX(DAMETH_MASK) == 0);
|
|
|
|
EDUKE32_STATIC_ASSERT(TO_PTH_NOTRANSFIX(DAMETH_TRANS1) == 0);
|
|
|
|
EDUKE32_STATIC_ASSERT(TO_PTH_NOTRANSFIX(DAMETH_MASKPROPS) == 0);
|
|
|
|
|
2015-04-14 08:07:41 +00:00
|
|
|
extern void gloadtile_art(int32_t,int32_t,int32_t,int32_t,int32_t,pthtyp *,int32_t);
|
2019-09-18 18:44:21 +00:00
|
|
|
extern int32_t gloadtile_hi(int32_t,int32_t,int32_t,hicreplctyp *,int32_t,pthtyp *,int32_t, polytintflags_t);
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t globalnoeffect;
|
|
|
|
extern int32_t drawingskybox;
|
2013-05-15 02:17:17 +00:00
|
|
|
extern int32_t hicprecaching;
|
2014-10-25 03:32:26 +00:00
|
|
|
extern float fcosglobalang, fsinglobalang;
|
2014-11-28 08:14:00 +00:00
|
|
|
extern float fxdim, fydim, fydimen, fviewingrange;
|
2009-04-24 02:53:50 +00:00
|
|
|
|
2013-05-15 02:17:17 +00:00
|
|
|
extern char ptempbuf[MAXWALLSB<<1];
|
|
|
|
|
2015-07-08 03:34:27 +00:00
|
|
|
extern hitdata_t polymost_hitdata;
|
|
|
|
|
2013-05-15 02:17:17 +00:00
|
|
|
#include "texcache.h"
|
|
|
|
|
2019-09-18 18:44:21 +00:00
|
|
|
extern void polymost_setupglowtexture(int32_t texunits, FHardwareTexture *tex);
|
|
|
|
extern void polymost_setupdetailtexture(int32_t texunits, FHardwareTexture* tex);
|
2014-09-30 04:14:21 +00:00
|
|
|
|
2008-12-02 10:44:39 +00:00
|
|
|
#endif
|