2008-12-03 11:05:16 +00:00
|
|
|
#ifndef _polymost_h_
|
|
|
|
# define _polymost_h_
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2011-03-04 08:50:58 +00:00
|
|
|
#ifdef USE_OPENGL
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2014-02-10 10:56:14 +00:00
|
|
|
#include "glbuild.h"
|
2009-08-09 05:32:17 +00:00
|
|
|
#include "hightile.h"
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
typedef struct { char r, g, b, a; } coltype;
|
2008-12-02 10:44:39 +00:00
|
|
|
|
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;
|
|
|
|
extern double gxyaspect, grhalfxdown10x;
|
|
|
|
extern double gcosang, gsinang, gcosang2, gsinang2;
|
2009-04-11 18:01:39 +00:00
|
|
|
extern double gchang, gshang, gctang, gstang, gvisibility;
|
2008-12-02 10:44:39 +00:00
|
|
|
|
|
|
|
struct glfiltermodes {
|
2011-02-21 23:08:21 +00:00
|
|
|
const char *name;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t min,mag;
|
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
|
|
|
|
2012-01-12 20:47:41 +00:00
|
|
|
//void phex(char v, char *s);
|
2009-01-09 09:29:17 +00:00
|
|
|
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 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,
|
2013-03-25 04:32:24 +00:00
|
|
|
int8_t dashade, char dapalnum, int32_t dastat, uint8_t daalpha, 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);
|
|
|
|
|
|
|
|
void polymost_glinit(void);
|
|
|
|
void polymost_glreset(void);
|
|
|
|
|
2013-05-15 02:20:08 +00:00
|
|
|
enum {
|
|
|
|
INVALIDATE_ALL,
|
|
|
|
INVALIDATE_ART
|
|
|
|
};
|
|
|
|
|
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;
|
2008-12-02 10:44:39 +00:00
|
|
|
extern float alphahackarray[MAXTILES];
|
2006-08-30 23:32:39 +00:00
|
|
|
|
2011-07-24 15:15:57 +00:00
|
|
|
extern int32_t r_usenewshading;
|
2013-05-15 02:18:27 +00:00
|
|
|
extern int32_t r_usetileshades;
|
2011-07-24 15:15:57 +00:00
|
|
|
|
2013-05-15 02:19:14 +00:00
|
|
|
extern int16_t globalpicnum;
|
|
|
|
extern int32_t globalpal;
|
|
|
|
|
2014-03-30 13:53:09 +00:00
|
|
|
// Compare with polymer_eligible_for_artmap()
|
2014-03-30 13:53:08 +00:00
|
|
|
static inline int32_t eligible_for_tileshades(int32_t picnum, int32_t pal)
|
|
|
|
{
|
|
|
|
return (!usehightile || !hicfindsubst(picnum, pal, 0)) &&
|
|
|
|
(!usemodels || md_tilehasmodel(picnum, pal) < 0);
|
|
|
|
}
|
|
|
|
|
2012-12-14 19:28:01 +00:00
|
|
|
static inline float getshadefactor(int32_t shade)
|
|
|
|
{
|
|
|
|
int32_t shadebound = (shadescale_unbounded || shade>=numshades) ? numshades : numshades-1;
|
|
|
|
float clamped_shade = min(max(shade*shadescale, 0), shadebound);
|
2014-03-25 21:04:33 +00:00
|
|
|
|
|
|
|
// 8-bit tiles, i.e. non-hightiles and non-models, don't get additional
|
|
|
|
// glColor() shading with r_usetileshades!
|
2013-05-17 03:44:09 +00:00
|
|
|
if (getrendermode() == REND_POLYMOST && r_usetileshades &&
|
2014-03-30 13:53:08 +00:00
|
|
|
eligible_for_tileshades(globalpicnum, globalpal))
|
2014-03-25 21:04:33 +00:00
|
|
|
return 1.f;
|
|
|
|
|
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))
|
2014-04-05 11:28:08 +00:00
|
|
|
static inline int32_t get_floor_fogpal(const sectortype *sec)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
static inline int32_t get_ceiling_fogpal(const sectortype *sec)
|
|
|
|
{
|
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
|
|
|
}
|
2014-05-01 22:02:21 +00:00
|
|
|
static inline int32_t fogpal_shade(const sectortype *sec, int32_t shade)
|
|
|
|
{
|
|
|
|
// When fogging is due to sector[].fogpal, don't make the fog parameters
|
|
|
|
// depend on the shade of the object.
|
|
|
|
return sec->fogpal ? 0 : shade;
|
|
|
|
}
|
2014-04-05 11:28:08 +00:00
|
|
|
|
2014-05-28 22:40:19 +00:00
|
|
|
static inline int check_nonpow2(int32_t xsiz, int32_t ysiz)
|
|
|
|
{
|
|
|
|
return (xsiz > 1 && (xsiz&(xsiz-1)))
|
|
|
|
|| (ysiz > 1 && (ysiz&(ysiz-1)));
|
|
|
|
}
|
|
|
|
|
2014-05-28 22:40:16 +00:00
|
|
|
// Flags of the <dameth> argument of various functions
|
|
|
|
enum {
|
|
|
|
DAMETH_CLAMPED = 4,
|
|
|
|
|
|
|
|
DAMETH_NOCOMPRESS = 4096,
|
|
|
|
DAMETH_HI = 8192,
|
|
|
|
};
|
|
|
|
|
|
|
|
// DAMETH_CLAMPED -> PTH_CLAMPED conversion
|
|
|
|
#define TO_PTH_CLAMPED(dameth) ((((dameth)&4))>>2)
|
|
|
|
|
|
|
|
// pthtyp pth->flags bits
|
|
|
|
enum {
|
|
|
|
PTH_CLAMPED = 1,
|
|
|
|
PTH_HIGHTILE = 2,
|
|
|
|
PTH_SKYBOX = 4,
|
|
|
|
PTH_HASALPHA = 8,
|
|
|
|
PTH_HASFULLBRIGHT = 16,
|
|
|
|
|
|
|
|
PTH_INVALIDATED = 128,
|
|
|
|
};
|
|
|
|
|
2006-08-30 23:32:39 +00:00
|
|
|
typedef struct pthtyp_t
|
|
|
|
{
|
|
|
|
struct pthtyp_t *next;
|
2009-01-09 09:29:17 +00:00
|
|
|
uint32_t glpic;
|
|
|
|
int16_t picnum;
|
2006-08-30 23:32:39 +00:00
|
|
|
char palnum;
|
2013-05-15 02:18:27 +00:00
|
|
|
char shade;
|
2006-08-30 23:32:39 +00:00
|
|
|
char effects;
|
|
|
|
char flags; // 1 = clamped (dameth&4), 2 = hightile, 4 = skybox face, 8 = hasalpha, 16 = hasfullbright, 128 = invalidated
|
|
|
|
char skyface;
|
|
|
|
hicreplctyp *hicr;
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
uint16_t sizx, sizy;
|
2006-08-30 23:32:39 +00:00
|
|
|
float scalex, scaley;
|
|
|
|
struct pthtyp_t *ofb; // only fullbright
|
2007-01-29 01:18:16 +00:00
|
|
|
} pthtyp;
|
|
|
|
|
2013-05-15 02:18:27 +00:00
|
|
|
extern int32_t gloadtile_art(int32_t,int32_t,int32_t,int32_t,pthtyp *,int32_t);
|
2013-05-15 02:17:17 +00:00
|
|
|
extern int32_t gloadtile_hi(int32_t,int32_t,int32_t,hicreplctyp *,int32_t,pthtyp *,int32_t,char);
|
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;
|
2012-12-14 19:28:09 +00:00
|
|
|
extern double gyxscale, gxyaspect, ghalfx, grhalfxdown10;
|
2009-04-24 02:53:50 +00:00
|
|
|
|
2013-05-15 02:17:17 +00:00
|
|
|
extern char ptempbuf[MAXWALLSB<<1];
|
|
|
|
|
2013-05-17 03:42:58 +00:00
|
|
|
static inline void polymost_setupdetailtexture(int32_t *texunits, int32_t tex)
|
|
|
|
{
|
|
|
|
bglActiveTextureARB(++*texunits);
|
|
|
|
|
|
|
|
bglEnable(GL_TEXTURE_2D);
|
|
|
|
bglBindTexture(GL_TEXTURE_2D, tex);
|
|
|
|
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
|
|
|
|
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE);
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB);
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
|
|
|
|
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.0f);
|
|
|
|
|
|
|
|
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
|
|
|
|
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void polymost_setupglowtexture(int32_t *texunits, int32_t tex)
|
|
|
|
{
|
|
|
|
bglActiveTextureARB(++*texunits);
|
|
|
|
|
|
|
|
bglEnable(GL_TEXTURE_2D);
|
|
|
|
bglBindTexture(GL_TEXTURE_2D, tex);
|
|
|
|
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB);
|
|
|
|
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE);
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
|
|
|
|
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_TEXTURE);
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB);
|
|
|
|
bglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
|
|
|
|
|
|
|
|
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
|
|
|
|
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
|
|
|
|
}
|
2013-05-15 02:17:17 +00:00
|
|
|
#include "texcache.h"
|
|
|
|
|
2008-12-02 10:44:39 +00:00
|
|
|
#endif
|
2008-05-05 09:05:07 +00:00
|
|
|
|
2008-12-03 11:05:16 +00:00
|
|
|
#endif
|