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;
|
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-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)));
|
|
|
|
}
|
|
|
|
|
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,
|
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);
|
2016-02-29 06:34:20 +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_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
|
|
|
|
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;
|
|
|
|
|
2019-10-10 17:30:05 +00:00
|
|
|
void gloadtile_art(int32_t dapic, int32_t dameth, pthtyp* pth, int32_t doalloc);
|
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
|