2014-06-02 02:23:08 +00:00
|
|
|
// Here lies the slow as shit renderer!
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#ifndef polymer_h_
|
|
|
|
# define polymer_h_
|
2007-01-29 01:18:16 +00:00
|
|
|
|
|
|
|
# include "compat.h"
|
2009-02-05 08:56:59 +00:00
|
|
|
# include "baselayer.h"
|
2007-01-29 01:18:16 +00:00
|
|
|
# include "glbuild.h"
|
2013-01-26 17:07:58 +00:00
|
|
|
# include "build.h"
|
2007-01-29 01:18:16 +00:00
|
|
|
# include "osd.h"
|
2008-12-02 10:44:39 +00:00
|
|
|
# include "hightile.h"
|
2008-05-05 09:05:07 +00:00
|
|
|
# include "mdsprite.h"
|
2008-12-02 10:44:39 +00:00
|
|
|
# include "polymost.h"
|
2006-09-27 17:55:49 +00:00
|
|
|
# include "pragmas.h"
|
2007-07-01 06:32:03 +00:00
|
|
|
|
2014-11-26 04:39:23 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-12-16 19:18:10 +00:00
|
|
|
#define PR_LINEAR_FOG
|
|
|
|
|
2007-01-29 01:18:16 +00:00
|
|
|
// CVARS
|
2009-04-12 17:14:18 +00:00
|
|
|
extern int32_t pr_lighting;
|
|
|
|
extern int32_t pr_normalmapping;
|
|
|
|
extern int32_t pr_specularmapping;
|
|
|
|
extern int32_t pr_shadows;
|
|
|
|
extern int32_t pr_shadowcount;
|
|
|
|
extern int32_t pr_shadowdetail;
|
2009-06-06 16:00:48 +00:00
|
|
|
extern int32_t pr_shadowfiltering;
|
2009-04-01 18:52:15 +00:00
|
|
|
extern int32_t pr_maxlightpasses;
|
2009-04-12 17:14:18 +00:00
|
|
|
extern int32_t pr_maxlightpriority;
|
2009-01-16 05:03:12 +00:00
|
|
|
extern int32_t pr_fov;
|
2013-05-15 14:53:54 +00:00
|
|
|
extern double pr_customaspect;
|
2009-01-16 05:03:12 +00:00
|
|
|
extern int32_t pr_billboardingmode;
|
|
|
|
extern int32_t pr_verbosity;
|
|
|
|
extern int32_t pr_wireframe;
|
|
|
|
extern int32_t pr_vbos;
|
2015-07-14 07:08:44 +00:00
|
|
|
extern int32_t pr_buckets;
|
2009-01-16 05:03:12 +00:00
|
|
|
extern int32_t pr_gpusmoothing;
|
2009-03-29 15:16:33 +00:00
|
|
|
extern int32_t pr_overrideparallax;
|
|
|
|
extern float pr_parallaxscale;
|
|
|
|
extern float pr_parallaxbias;
|
2009-03-29 17:14:41 +00:00
|
|
|
extern int32_t pr_overridespecular;
|
|
|
|
extern float pr_specularpower;
|
|
|
|
extern float pr_specularfactor;
|
2010-12-30 08:13:37 +00:00
|
|
|
extern int32_t pr_highpalookups;
|
2013-05-06 03:12:38 +00:00
|
|
|
extern int32_t pr_artmapping;
|
2011-03-01 05:52:33 +00:00
|
|
|
extern int32_t pr_overridehud;
|
|
|
|
extern float pr_hudxadd;
|
|
|
|
extern float pr_hudyadd;
|
|
|
|
extern float pr_hudzadd;
|
|
|
|
extern int32_t pr_hudangadd;
|
|
|
|
extern int32_t pr_hudfov;
|
2011-03-04 05:33:35 +00:00
|
|
|
extern float pr_overridemodelscale;
|
2009-06-28 21:03:50 +00:00
|
|
|
extern int32_t pr_ati_fboworkaround;
|
2009-06-28 21:16:11 +00:00
|
|
|
extern int32_t pr_ati_nodepthoffset;
|
2010-01-23 22:12:02 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
extern int32_t pr_ati_textureformat_one;
|
|
|
|
#endif
|
2015-06-14 23:42:31 +00:00
|
|
|
extern int32_t pr_nullrender;
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2009-06-09 02:12:35 +00:00
|
|
|
extern int32_t r_pr_maxlightpasses;
|
|
|
|
|
2008-11-25 10:42:22 +00:00
|
|
|
// MATERIAL
|
2008-11-27 22:26:46 +00:00
|
|
|
typedef enum {
|
2009-02-05 08:56:59 +00:00
|
|
|
PR_BIT_HEADER, // must be first
|
2008-11-27 22:26:46 +00:00
|
|
|
PR_BIT_ANIM_INTERPOLATION,
|
2009-03-12 13:51:30 +00:00
|
|
|
PR_BIT_LIGHTING_PASS,
|
2009-03-13 15:18:46 +00:00
|
|
|
PR_BIT_NORMAL_MAP,
|
2013-05-06 03:12:38 +00:00
|
|
|
PR_BIT_ART_MAP,
|
2008-11-27 22:26:46 +00:00
|
|
|
PR_BIT_DIFFUSE_MAP,
|
|
|
|
PR_BIT_DIFFUSE_DETAIL_MAP,
|
|
|
|
PR_BIT_DIFFUSE_MODULATION,
|
2011-01-12 02:31:50 +00:00
|
|
|
PR_BIT_DIFFUSE_MAP2,
|
2011-01-18 01:34:39 +00:00
|
|
|
PR_BIT_HIGHPALOOKUP_MAP,
|
2009-03-28 16:14:10 +00:00
|
|
|
PR_BIT_SPECULAR_MAP,
|
2009-03-28 12:14:37 +00:00
|
|
|
PR_BIT_SPECULAR_MATERIAL,
|
2009-03-28 11:43:16 +00:00
|
|
|
PR_BIT_MIRROR_MAP,
|
2009-04-11 18:01:39 +00:00
|
|
|
PR_BIT_FOG,
|
2009-03-28 11:43:16 +00:00
|
|
|
PR_BIT_GLOW_MAP,
|
2010-07-25 02:16:22 +00:00
|
|
|
PR_BIT_PROJECTION_MAP,
|
2009-03-26 16:32:00 +00:00
|
|
|
PR_BIT_SHADOW_MAP,
|
2009-05-12 20:08:38 +00:00
|
|
|
PR_BIT_LIGHT_MAP,
|
2009-03-25 19:48:27 +00:00
|
|
|
PR_BIT_SPOT_LIGHT,
|
2009-03-12 13:51:30 +00:00
|
|
|
PR_BIT_POINT_LIGHT,
|
2009-02-05 08:56:59 +00:00
|
|
|
PR_BIT_FOOTER, // must be just before last
|
|
|
|
PR_BIT_COUNT // must be last
|
2008-11-27 22:26:46 +00:00
|
|
|
} prbittype;
|
|
|
|
|
2008-11-25 10:42:22 +00:00
|
|
|
typedef struct s_prmaterial {
|
2008-11-27 16:19:24 +00:00
|
|
|
// PR_BIT_ANIM_INTERPOLATION
|
|
|
|
GLfloat frameprogress;
|
|
|
|
GLfloat* nextframedata;
|
2009-03-13 15:18:46 +00:00
|
|
|
// PR_BIT_NORMAL_MAP
|
|
|
|
GLuint normalmap;
|
2009-03-29 15:16:33 +00:00
|
|
|
GLfloat normalbias[2];
|
2010-01-24 05:57:43 +00:00
|
|
|
GLfloat* tbn;
|
2013-05-06 03:12:38 +00:00
|
|
|
// PR_BIT_ART_MAP
|
|
|
|
GLuint artmap;
|
|
|
|
GLuint basepalmap;
|
|
|
|
GLuint lookupmap;
|
2013-05-07 07:48:08 +00:00
|
|
|
GLint shadeoffset;
|
|
|
|
GLfloat visibility;
|
2008-11-27 16:19:24 +00:00
|
|
|
// PR_BIT_DIFFUSE_MAP
|
2008-11-25 10:42:22 +00:00
|
|
|
GLuint diffusemap;
|
2008-11-27 22:26:46 +00:00
|
|
|
GLfloat diffusescale[2];
|
2010-12-29 06:23:49 +00:00
|
|
|
// PR_BIT_HIGHPALOOKUP_MAP
|
|
|
|
GLuint highpalookupmap;
|
2008-11-27 22:26:46 +00:00
|
|
|
// PR_BIT_DIFFUSE_DETAIL_MAP
|
|
|
|
GLuint detailmap;
|
|
|
|
GLfloat detailscale[2];
|
2008-11-27 16:19:24 +00:00
|
|
|
// PR_BIT_DIFFUSE_MODULATION
|
2009-12-07 07:01:44 +00:00
|
|
|
GLubyte diffusemodulation[4];
|
2009-03-28 16:14:10 +00:00
|
|
|
// PR_BIT_SPECULAR_MAP
|
|
|
|
GLuint specmap;
|
2009-03-28 12:14:37 +00:00
|
|
|
// PR_BIT_SPECULAR_MATERIAL
|
|
|
|
GLfloat specmaterial[2];
|
2009-03-28 11:43:16 +00:00
|
|
|
// PR_BIT_MIRROR_MAP
|
2009-03-23 14:18:20 +00:00
|
|
|
GLuint mirrormap;
|
2009-03-28 11:43:16 +00:00
|
|
|
// PR_BIT_GLOW_MAP
|
2008-11-27 23:00:57 +00:00
|
|
|
GLuint glowmap;
|
2009-03-27 12:56:42 +00:00
|
|
|
// PR_BIT_SHADOW_MAP
|
|
|
|
GLboolean mdspritespace;
|
2008-11-25 10:42:22 +00:00
|
|
|
} _prmaterial;
|
|
|
|
|
2008-11-27 22:26:46 +00:00
|
|
|
typedef struct s_prrograminfo {
|
|
|
|
GLhandleARB handle;
|
|
|
|
// PR_BIT_ANIM_INTERPOLATION
|
|
|
|
GLint attrib_nextFrameData;
|
2009-03-10 14:30:34 +00:00
|
|
|
GLint attrib_nextFrameNormal;
|
2008-11-27 22:26:46 +00:00
|
|
|
GLint uniform_frameProgress;
|
2009-03-13 15:18:46 +00:00
|
|
|
// PR_BIT_NORMAL_MAP
|
|
|
|
GLint attrib_T;
|
|
|
|
GLint attrib_B;
|
|
|
|
GLint attrib_N;
|
2009-03-28 18:25:30 +00:00
|
|
|
GLint uniform_eyePosition;
|
|
|
|
GLint uniform_normalMap;
|
2009-03-29 15:16:33 +00:00
|
|
|
GLint uniform_normalBias;
|
2013-05-06 03:12:38 +00:00
|
|
|
// PR_BIT_ART_MAP
|
|
|
|
GLuint uniform_artMap;
|
|
|
|
GLuint uniform_basePalMap;
|
|
|
|
GLuint uniform_lookupMap;
|
2013-05-07 07:48:08 +00:00
|
|
|
GLuint uniform_shadeOffset;
|
|
|
|
GLuint uniform_visibility;
|
2008-11-27 22:26:46 +00:00
|
|
|
// PR_BIT_DIFFUSE_MAP
|
|
|
|
GLint uniform_diffuseMap;
|
|
|
|
GLint uniform_diffuseScale;
|
2010-12-29 06:23:49 +00:00
|
|
|
// PR_BIT_HIGHPALOOKUP_MAP
|
|
|
|
GLuint uniform_highPalookupMap;
|
2008-11-27 22:26:46 +00:00
|
|
|
// PR_BIT_DIFFUSE_DETAIL_MAP
|
|
|
|
GLint uniform_detailMap;
|
|
|
|
GLint uniform_detailScale;
|
2009-03-28 16:14:10 +00:00
|
|
|
// PR_BIT_SPECULAR_MAP
|
|
|
|
GLint uniform_specMap;
|
2009-03-28 12:14:37 +00:00
|
|
|
// PR_BIT_SPECULAR_MATERIAL
|
|
|
|
GLint uniform_specMaterial;
|
2009-03-28 11:43:16 +00:00
|
|
|
// PR_BIT_MIRROR_MAP
|
2009-03-23 14:18:20 +00:00
|
|
|
GLint uniform_mirrorMap;
|
2012-12-16 19:18:10 +00:00
|
|
|
#ifdef PR_LINEAR_FOG
|
|
|
|
// PR_BIT_FOG
|
|
|
|
GLint uniform_linearFog;
|
|
|
|
#endif
|
2009-03-28 11:43:16 +00:00
|
|
|
// PR_BIT_GLOW_MAP
|
2008-11-27 23:00:57 +00:00
|
|
|
GLint uniform_glowMap;
|
2010-07-25 02:16:22 +00:00
|
|
|
// PR_BIT_PROJECTION_MAP
|
|
|
|
GLint uniform_shadowProjMatrix;
|
2009-03-26 16:32:00 +00:00
|
|
|
// PR_BIT_SHADOW_MAP
|
|
|
|
GLint uniform_shadowMap;
|
2009-05-12 20:08:38 +00:00
|
|
|
// PR_BIT_LIGHT_MAP
|
|
|
|
GLint uniform_lightMap;
|
2009-03-25 19:48:27 +00:00
|
|
|
// PR_BIT_SPOT_LIGHT
|
|
|
|
GLint uniform_spotDir;
|
|
|
|
GLint uniform_spotRadius;
|
2008-11-27 22:26:46 +00:00
|
|
|
} _prprograminfo;
|
|
|
|
|
2009-04-14 13:58:38 +00:00
|
|
|
#define PR_INFO_LOG_BUFFER_SIZE 8192
|
2011-01-27 07:57:52 +00:00
|
|
|
|
|
|
|
// Think about changing highPal[Scale|Bias] in the program bit if you change this
|
|
|
|
#define PR_HIGHPALOOKUP_BIT_DEPTH 6
|
2010-12-30 08:13:37 +00:00
|
|
|
#define PR_HIGHPALOOKUP_DIM (1 << PR_HIGHPALOOKUP_BIT_DEPTH)
|
|
|
|
#define PR_HIGHPALOOKUP_DATA_SIZE (4 * PR_HIGHPALOOKUP_DIM * \
|
|
|
|
PR_HIGHPALOOKUP_DIM * \
|
|
|
|
PR_HIGHPALOOKUP_DIM)
|
2008-11-27 22:26:46 +00:00
|
|
|
|
|
|
|
typedef struct s_prprogrambit {
|
2009-01-16 05:03:12 +00:00
|
|
|
int32_t bit;
|
2012-07-01 22:11:33 +00:00
|
|
|
const char* vert_def;
|
|
|
|
const char* vert_prog;
|
|
|
|
const char* frag_def;
|
|
|
|
const char* frag_prog;
|
2008-11-27 22:26:46 +00:00
|
|
|
} _prprogrambit;
|
|
|
|
|
2015-07-14 07:08:44 +00:00
|
|
|
typedef struct s_prbucket {
|
|
|
|
// index
|
|
|
|
int16_t tilenum;
|
|
|
|
char pal;
|
|
|
|
|
|
|
|
_prmaterial material;
|
|
|
|
int32_t invalidmaterial;
|
|
|
|
|
|
|
|
// geom indices
|
|
|
|
GLuint* indices;
|
|
|
|
uint32_t count;
|
|
|
|
uint32_t buffersize;
|
2015-07-15 08:23:00 +00:00
|
|
|
GLuint* indiceoffset;
|
2015-07-14 07:08:44 +00:00
|
|
|
|
|
|
|
struct s_prbucket* next;
|
|
|
|
} _prbucket;
|
|
|
|
|
2010-06-23 04:20:46 +00:00
|
|
|
#include "prlights.h"
|
2009-04-12 13:02:36 +00:00
|
|
|
|
2009-06-06 13:12:29 +00:00
|
|
|
// RENDER TARGETS
|
|
|
|
typedef struct s_prrt {
|
|
|
|
GLenum target;
|
|
|
|
GLuint color;
|
|
|
|
GLuint z;
|
|
|
|
GLuint fbo;
|
|
|
|
int32_t xdim, ydim;
|
|
|
|
} _prrt;
|
|
|
|
|
|
|
|
// BUILD DATA
|
2015-07-13 03:46:35 +00:00
|
|
|
|
|
|
|
typedef struct s_prvert {
|
|
|
|
GLfloat x;
|
|
|
|
GLfloat y;
|
|
|
|
GLfloat z;
|
|
|
|
GLfloat u;
|
|
|
|
GLfloat v;
|
|
|
|
GLubyte r;
|
|
|
|
GLubyte g;
|
|
|
|
GLubyte b;
|
|
|
|
GLubyte a;
|
|
|
|
} _prvert;
|
|
|
|
|
2009-06-06 13:12:29 +00:00
|
|
|
typedef struct s_prplane {
|
|
|
|
// geometry
|
2015-07-13 03:46:35 +00:00
|
|
|
_prvert* buffer;
|
2009-06-06 13:12:29 +00:00
|
|
|
int32_t vertcount;
|
|
|
|
GLuint vbo;
|
2015-07-14 07:08:44 +00:00
|
|
|
uint32_t mapvbo_vertoffset;
|
|
|
|
_prbucket* bucket;
|
2009-06-06 13:12:29 +00:00
|
|
|
// attributes
|
2010-01-24 05:57:43 +00:00
|
|
|
GLfloat tbn[3][3];
|
2009-06-06 13:12:29 +00:00
|
|
|
GLfloat plane[4];
|
|
|
|
_prmaterial material;
|
|
|
|
// elements
|
|
|
|
GLushort* indices;
|
|
|
|
int32_t indicescount;
|
|
|
|
GLuint ivbo;
|
|
|
|
// lights
|
|
|
|
int16_t lights[PR_MAXLIGHTS];
|
2009-06-09 02:12:35 +00:00
|
|
|
uint16_t lightcount;
|
2009-06-06 13:12:29 +00:00
|
|
|
} _prplane;
|
2008-05-18 07:35:35 +00:00
|
|
|
|
|
|
|
typedef struct s_prsector {
|
|
|
|
// polymer data
|
|
|
|
GLdouble* verts;
|
|
|
|
_prplane floor;
|
|
|
|
_prplane ceil;
|
2009-01-16 05:03:12 +00:00
|
|
|
int16_t curindice;
|
|
|
|
int32_t indicescount;
|
|
|
|
int32_t oldindicescount;
|
2008-03-30 14:22:03 +00:00
|
|
|
// stuff
|
|
|
|
float wallsproffset;
|
|
|
|
float floorsproffset;
|
2008-04-02 06:58:26 +00:00
|
|
|
// build sector data
|
2009-01-16 05:03:12 +00:00
|
|
|
int32_t ceilingz, floorz;
|
2014-09-30 04:04:30 +00:00
|
|
|
uint16_t ceilingstat, floorstat;
|
2009-01-16 05:03:12 +00:00
|
|
|
int16_t ceilingpicnum, ceilingheinum;
|
|
|
|
int8_t ceilingshade;
|
2014-09-30 04:04:30 +00:00
|
|
|
uint8_t ceilingpal, ceilingxpanning, ceilingypanning;
|
2009-01-16 05:03:12 +00:00
|
|
|
int16_t floorpicnum, floorheinum;
|
|
|
|
int8_t floorshade;
|
2014-09-30 04:04:30 +00:00
|
|
|
uint8_t floorpal, floorxpanning, floorypanning;
|
2013-05-07 07:48:08 +00:00
|
|
|
uint8_t visibility;
|
2006-09-27 17:55:49 +00:00
|
|
|
|
2014-09-30 04:04:30 +00:00
|
|
|
int16_t floorpicnum_anim, ceilingpicnum_anim;
|
|
|
|
|
2009-06-09 09:32:23 +00:00
|
|
|
struct {
|
|
|
|
int32_t empty : 1;
|
|
|
|
int32_t uptodate : 1;
|
|
|
|
int32_t invalidtex : 1;
|
|
|
|
} flags;
|
2009-01-16 05:03:12 +00:00
|
|
|
uint32_t invalidid;
|
2015-12-23 04:05:47 +00:00
|
|
|
uint32_t trackedrev;
|
2006-09-27 02:23:27 +00:00
|
|
|
} _prsector;
|
2006-09-29 21:36:12 +00:00
|
|
|
|
|
|
|
typedef struct s_prwall {
|
2008-05-18 07:35:35 +00:00
|
|
|
_prplane wall;
|
|
|
|
_prplane over;
|
|
|
|
_prplane mask;
|
2014-09-30 04:04:30 +00:00
|
|
|
|
2008-05-18 07:35:35 +00:00
|
|
|
// stuff
|
2008-04-03 06:58:36 +00:00
|
|
|
GLfloat* bigportal;
|
2015-07-13 03:46:35 +00:00
|
|
|
//GLfloat* cap;
|
2008-05-24 09:37:09 +00:00
|
|
|
GLuint stuffvbo;
|
2014-09-30 04:04:30 +00:00
|
|
|
|
2008-04-09 07:27:17 +00:00
|
|
|
// build wall data
|
2014-09-30 04:04:30 +00:00
|
|
|
uint16_t cstat;
|
|
|
|
int16_t picnum, overpicnum;
|
2009-01-16 05:03:12 +00:00
|
|
|
int8_t shade;
|
2014-09-30 04:04:30 +00:00
|
|
|
uint8_t pal, xrepeat, yrepeat, xpanning, ypanning;
|
|
|
|
|
|
|
|
// nextwall data
|
|
|
|
int16_t nwallpicnum, nwallcstat;
|
|
|
|
int8_t nwallxpanning, nwallypanning;
|
2011-02-13 23:37:35 +00:00
|
|
|
int8_t nwallshade;
|
2008-04-02 08:49:21 +00:00
|
|
|
|
2014-09-30 04:04:30 +00:00
|
|
|
int16_t picnum_anim, overpicnum_anim;
|
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
char underover;
|
2009-01-16 05:03:12 +00:00
|
|
|
uint32_t invalidid;
|
2009-06-09 09:32:23 +00:00
|
|
|
struct {
|
|
|
|
int32_t empty : 1;
|
|
|
|
int32_t uptodate : 1;
|
|
|
|
int32_t invalidtex : 1;
|
|
|
|
} flags;
|
2015-12-23 04:05:47 +00:00
|
|
|
uint32_t trackedrev;
|
2006-09-29 21:36:12 +00:00
|
|
|
} _prwall;
|
|
|
|
|
2010-07-26 22:36:45 +00:00
|
|
|
typedef struct s_prsprite {
|
|
|
|
_prplane plane;
|
2015-12-23 04:05:47 +00:00
|
|
|
uint32_t trackedrev;
|
2010-07-26 22:36:45 +00:00
|
|
|
} _prsprite;
|
|
|
|
|
2009-03-23 14:18:20 +00:00
|
|
|
typedef struct s_prmirror {
|
|
|
|
_prplane *plane;
|
|
|
|
int16_t sectnum;
|
|
|
|
int16_t wallnum;
|
|
|
|
} _prmirror;
|
|
|
|
|
2010-12-30 08:13:37 +00:00
|
|
|
typedef struct s_prhighpalookup {
|
|
|
|
char *data;
|
|
|
|
GLuint map;
|
|
|
|
} _prhighpalookup;
|
|
|
|
|
2009-02-14 14:31:58 +00:00
|
|
|
typedef void (*animatespritesptr)(int32_t, int32_t, int32_t, int32_t);
|
|
|
|
|
2008-04-06 23:35:48 +00:00
|
|
|
typedef struct s_pranimatespritesinfo {
|
|
|
|
animatespritesptr animatesprites;
|
2009-01-16 05:03:12 +00:00
|
|
|
int32_t x, y, a, smoothratio;
|
2008-04-06 23:35:48 +00:00
|
|
|
} _pranimatespritesinfo;
|
2006-10-14 23:33:10 +00:00
|
|
|
|
2011-09-06 17:45:21 +00:00
|
|
|
// this one has to be provided by the application
|
|
|
|
extern void G_Polymer_UnInit(void);
|
|
|
|
|
2006-09-29 21:36:12 +00:00
|
|
|
// EXTERNAL FUNCTIONS
|
2009-01-16 05:03:12 +00:00
|
|
|
int32_t polymer_init(void);
|
2009-05-22 23:49:25 +00:00
|
|
|
void polymer_uninit(void);
|
2011-03-01 05:52:33 +00:00
|
|
|
void polymer_setaspect(int32_t);
|
2006-09-29 21:36:12 +00:00
|
|
|
void polymer_glinit(void);
|
2010-01-24 23:33:17 +00:00
|
|
|
void polymer_resetlights(void);
|
2006-09-29 21:36:12 +00:00
|
|
|
void polymer_loadboard(void);
|
2009-01-09 09:29:17 +00:00
|
|
|
void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, int16_t daang, int32_t dahoriz, int16_t dacursectnum);
|
2008-03-30 09:16:39 +00:00
|
|
|
void polymer_drawmasks(void);
|
2009-12-07 07:01:44 +00:00
|
|
|
void polymer_editorpick(void);
|
2015-12-04 11:52:58 +00:00
|
|
|
void polymer_inb4rotatesprite(int16_t tilenum, char pal, int8_t shade, int32_t method);
|
2011-02-28 03:56:37 +00:00
|
|
|
void polymer_postrotatesprite(void);
|
2009-01-09 09:29:17 +00:00
|
|
|
void polymer_drawmaskwall(int32_t damaskwallcnt);
|
|
|
|
void polymer_drawsprite(int32_t snum);
|
2009-02-14 14:31:58 +00:00
|
|
|
void polymer_setanimatesprites(animatespritesptr animatesprites, int32_t x, int32_t y, int32_t a, int32_t smoothratio);
|
2009-06-01 20:55:36 +00:00
|
|
|
int16_t polymer_addlight(_prlight* light);
|
|
|
|
void polymer_deletelight(int16_t lighti);
|
2009-06-09 02:12:35 +00:00
|
|
|
void polymer_invalidatelights(void);
|
2009-06-09 09:32:23 +00:00
|
|
|
void polymer_texinvalidate(void);
|
2011-01-27 07:05:12 +00:00
|
|
|
void polymer_definehighpalookup(char basepalnum, char palnum, char *fn);
|
2011-09-28 20:30:24 +00:00
|
|
|
int32_t polymer_havehighpalookup(int32_t basepalnum, int32_t palnum);
|
2008-04-02 09:29:58 +00:00
|
|
|
|
2015-01-11 04:52:15 +00:00
|
|
|
|
|
|
|
extern _prsprite *prsprites[MAXSPRITES];
|
2014-02-08 14:37:52 +00:00
|
|
|
static inline void polymer_invalidatesprite(int32_t i)
|
|
|
|
{
|
|
|
|
if (prsprites[i])
|
2015-12-23 04:05:47 +00:00
|
|
|
prsprites[i]->trackedrev = UINT32_MAX;
|
2014-02-08 14:37:52 +00:00
|
|
|
}
|
|
|
|
|
2015-01-11 04:52:15 +00:00
|
|
|
extern GLuint prartmaps[MAXTILES];
|
2014-02-08 14:37:53 +00:00
|
|
|
static inline void polymer_invalidateartmap(int32_t tilenum)
|
|
|
|
{
|
|
|
|
if (prartmaps[tilenum])
|
|
|
|
{
|
|
|
|
bglDeleteTextures(1, &prartmaps[tilenum]);
|
|
|
|
prartmaps[tilenum] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-30 13:53:09 +00:00
|
|
|
// Compare with eligible_for_tileshades()
|
|
|
|
static inline int32_t polymer_eligible_for_artmap(int32_t tilenum, const pthtyp *pth)
|
|
|
|
{
|
|
|
|
return ((!pth || !pth->hicr) && tilenum < (MAXTILES - 4));
|
|
|
|
}
|
|
|
|
|
2008-04-02 09:29:58 +00:00
|
|
|
# ifdef POLYMER_C
|
|
|
|
|
2008-04-06 03:00:39 +00:00
|
|
|
// CORE
|
2009-01-09 09:29:17 +00:00
|
|
|
static void polymer_displayrooms(int16_t sectnum);
|
2015-07-14 07:08:44 +00:00
|
|
|
static void polymer_emptybuckets(void);
|
|
|
|
static _prbucket* polymer_findbucket(int16_t tilenum, char pal);
|
|
|
|
static void polymer_bucketplane(_prplane* plane);
|
2009-03-23 14:18:20 +00:00
|
|
|
static void polymer_drawplane(_prplane* plane);
|
2015-07-13 03:46:35 +00:00
|
|
|
static inline void polymer_inb4mirror(_prvert* buffer, GLfloat* plane);
|
2008-04-06 23:35:48 +00:00
|
|
|
static void polymer_animatesprites(void);
|
2009-05-22 23:49:25 +00:00
|
|
|
static void polymer_freeboard(void);
|
2006-10-15 18:51:41 +00:00
|
|
|
// SECTORS
|
2009-01-16 05:03:12 +00:00
|
|
|
static int32_t polymer_initsector(int16_t sectnum);
|
|
|
|
static int32_t polymer_updatesector(int16_t sectnum);
|
2006-09-29 21:36:12 +00:00
|
|
|
void PR_CALLBACK polymer_tesserror(GLenum error);
|
|
|
|
void PR_CALLBACK polymer_tessedgeflag(GLenum error);
|
|
|
|
void PR_CALLBACK polymer_tessvertex(void* vertex, void* sector);
|
2009-01-16 05:03:12 +00:00
|
|
|
static int32_t polymer_buildfloor(int16_t sectnum);
|
2011-08-20 21:05:38 +00:00
|
|
|
static void polymer_drawsector(int16_t sectnum, int32_t domasks);
|
2006-10-15 18:51:41 +00:00
|
|
|
// WALLS
|
2009-01-16 05:03:12 +00:00
|
|
|
static int32_t polymer_initwall(int16_t wallnum);
|
2009-01-09 09:29:17 +00:00
|
|
|
static void polymer_updatewall(int16_t wallnum);
|
|
|
|
static void polymer_drawwall(int16_t sectnum, int16_t wallnum);
|
2006-10-14 23:33:10 +00:00
|
|
|
// HSR
|
2009-04-19 17:23:07 +00:00
|
|
|
static void polymer_computeplane(_prplane* p);
|
2009-04-12 21:52:49 +00:00
|
|
|
static inline void polymer_crossproduct(GLfloat* in_a, GLfloat* in_b, GLfloat* out);
|
2010-07-26 22:36:45 +00:00
|
|
|
static inline void polymer_transformpoint(const float* inpos, float* pos, float* matrix);
|
2010-01-21 05:52:19 +00:00
|
|
|
static inline void polymer_normalize(float* vec);
|
2009-04-12 21:52:49 +00:00
|
|
|
static inline void polymer_pokesector(int16_t sectnum);
|
2009-01-14 14:13:51 +00:00
|
|
|
static void polymer_extractfrustum(GLfloat* modelview, GLfloat* projection, float* frustum);
|
2009-06-13 21:06:45 +00:00
|
|
|
static inline int32_t polymer_planeinfrustum(_prplane *plane, float* frustum);
|
2015-01-11 04:55:07 +00:00
|
|
|
static inline void polymer_scansprites(int16_t sectnum, tspritetype* tsprite, int32_t* spritesortcnt);
|
2011-08-20 21:04:28 +00:00
|
|
|
static void polymer_updatesprite(int32_t snum);
|
2006-10-18 03:59:28 +00:00
|
|
|
// SKIES
|
2008-04-02 09:29:58 +00:00
|
|
|
static void polymer_getsky(void);
|
2009-06-07 18:38:13 +00:00
|
|
|
static void polymer_drawsky(int16_t tilenum, char palnum, int8_t shade);
|
2008-06-09 09:25:47 +00:00
|
|
|
static void polymer_initartsky(void);
|
2009-06-07 18:38:13 +00:00
|
|
|
static void polymer_drawartsky(int16_t tilenum, char palnum, int8_t shade);
|
2009-01-09 09:29:17 +00:00
|
|
|
static void polymer_drawartskyquad(int32_t p1, int32_t p2, GLfloat height);
|
2009-06-07 18:38:13 +00:00
|
|
|
static void polymer_drawskybox(int16_t tilenum, char palnum, int8_t shade);
|
2008-06-01 08:58:06 +00:00
|
|
|
// MDSPRITES
|
2015-01-11 04:55:07 +00:00
|
|
|
static void polymer_drawmdsprite(tspritetype *tspr);
|
2009-01-10 07:38:50 +00:00
|
|
|
static void polymer_loadmodelvbos(md3model_t* m);
|
2008-11-26 14:22:07 +00:00
|
|
|
// MATERIALS
|
2008-11-27 16:19:24 +00:00
|
|
|
static void polymer_getscratchmaterial(_prmaterial* material);
|
2015-07-14 07:08:44 +00:00
|
|
|
static _prbucket* polymer_getbuildmaterial(_prmaterial* material, int16_t tilenum, char pal, int8_t shade, int8_t vis, int32_t cmeth);
|
2014-09-30 04:04:30 +00:00
|
|
|
static int32_t polymer_bindmaterial(const _prmaterial *material, int16_t* lights, int lightcount);
|
2009-01-09 09:29:17 +00:00
|
|
|
static void polymer_unbindmaterial(int32_t programbits);
|
|
|
|
static void polymer_compileprogram(int32_t programbits);
|
2009-02-14 14:31:58 +00:00
|
|
|
// LIGHTS
|
2009-06-01 20:55:36 +00:00
|
|
|
static void polymer_removelight(int16_t lighti);
|
|
|
|
static void polymer_updatelights(void);
|
2009-06-08 00:31:53 +00:00
|
|
|
static inline void polymer_resetplanelights(_prplane* plane);
|
2009-06-01 20:55:36 +00:00
|
|
|
static void polymer_addplanelight(_prplane* plane, int16_t lighti);
|
2009-06-06 22:30:53 +00:00
|
|
|
static inline void polymer_deleteplanelight(_prplane* plane, int16_t lighti);
|
2009-03-08 20:38:51 +00:00
|
|
|
static int32_t polymer_planeinlight(_prplane* plane, _prlight* light);
|
2009-06-01 20:55:36 +00:00
|
|
|
static void polymer_invalidateplanelights(_prplane* plane);
|
|
|
|
static void polymer_invalidatesectorlights(int16_t sectnum);
|
|
|
|
static void polymer_processspotlight(_prlight* light);
|
|
|
|
static inline void polymer_culllight(int16_t lighti);
|
2009-03-26 16:32:00 +00:00
|
|
|
static void polymer_prepareshadows(void);
|
2009-03-23 14:18:20 +00:00
|
|
|
// RENDER TARGETS
|
|
|
|
static void polymer_initrendertargets(int32_t count);
|
2011-10-02 05:56:35 +00:00
|
|
|
// DEBUG OUTPUT
|
2011-10-03 00:14:56 +00:00
|
|
|
void PR_CALLBACK polymer_debugoutputcallback(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam);
|
2008-04-02 09:29:58 +00:00
|
|
|
|
2015-07-13 03:46:35 +00:00
|
|
|
#define INDICE(n) ((p->indices) ? (p->indices[(i+n)%p->indicescount]) : (((i+n)%p->vertcount)))
|
2011-08-20 21:04:28 +00:00
|
|
|
|
2011-10-02 00:32:00 +00:00
|
|
|
#define SWITCH_CULL_DIRECTION { culledface = (culledface == GL_FRONT) ? GL_BACK : GL_FRONT; bglCullFace(culledface); }
|
2011-09-18 07:18:50 +00:00
|
|
|
|
2011-08-20 21:04:28 +00:00
|
|
|
static inline GLfloat dot2f(GLfloat *v1, GLfloat *v2)
|
|
|
|
{
|
|
|
|
return v1[0]*v2[0] + v1[1]*v2[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline GLfloat dot3f(GLfloat *v1, GLfloat *v2)
|
|
|
|
{
|
|
|
|
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void relvec2f(GLfloat *v1, GLfloat *v2, GLfloat *out)
|
|
|
|
{
|
|
|
|
out[0] = v2[0]-v1[0];
|
|
|
|
out[1] = v2[1]-v1[1];
|
|
|
|
}
|
|
|
|
|
2010-01-24 05:57:43 +00:00
|
|
|
// the following from gle/vvector.h
|
|
|
|
|
2010-07-25 02:16:22 +00:00
|
|
|
/* ========================================================== */
|
|
|
|
/* determinant of matrix
|
|
|
|
*
|
|
|
|
* Computes determinant of matrix m, returning d
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DETERMINANT_3X3(d,m) \
|
|
|
|
{ \
|
|
|
|
d = m[0][0] * (m[1][1]*m[2][2] - m[1][2] * m[2][1]); \
|
|
|
|
d -= m[0][1] * (m[1][0]*m[2][2] - m[1][2] * m[2][0]); \
|
|
|
|
d += m[0][2] * (m[1][0]*m[2][1] - m[1][1] * m[2][0]); \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ========================================================== */
|
|
|
|
/* i,j,th cofactor of a 4x4 matrix
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COFACTOR_4X4_IJ(fac,m,i,j) \
|
|
|
|
{ \
|
|
|
|
int ii[4], jj[4], k; \
|
|
|
|
\
|
|
|
|
/* compute which row, columnt to skip */ \
|
|
|
|
for (k=0; k<i; k++) ii[k] = k; \
|
|
|
|
for (k=i; k<3; k++) ii[k] = k+1; \
|
|
|
|
for (k=0; k<j; k++) jj[k] = k; \
|
|
|
|
for (k=j; k<3; k++) jj[k] = k+1; \
|
|
|
|
\
|
|
|
|
(fac) = m[ii[0]][jj[0]] * (m[ii[1]][jj[1]]*m[ii[2]][jj[2]] \
|
|
|
|
- m[ii[1]][jj[2]]*m[ii[2]][jj[1]]); \
|
|
|
|
(fac) -= m[ii[0]][jj[1]] * (m[ii[1]][jj[0]]*m[ii[2]][jj[2]] \
|
|
|
|
- m[ii[1]][jj[2]]*m[ii[2]][jj[0]]);\
|
|
|
|
(fac) += m[ii[0]][jj[2]] * (m[ii[1]][jj[0]]*m[ii[2]][jj[1]] \
|
|
|
|
- m[ii[1]][jj[1]]*m[ii[2]][jj[0]]);\
|
|
|
|
\
|
|
|
|
/* compute sign */ \
|
|
|
|
k = i+j; \
|
|
|
|
if ( k != (k/2)*2) { \
|
|
|
|
(fac) = -(fac); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ========================================================== */
|
|
|
|
/* determinant of matrix
|
|
|
|
*
|
|
|
|
* Computes determinant of matrix m, returning d
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DETERMINANT_4X4(d,m) \
|
|
|
|
{ \
|
|
|
|
double cofac; \
|
|
|
|
COFACTOR_4X4_IJ (cofac, m, 0, 0); \
|
|
|
|
d = m[0][0] * cofac; \
|
|
|
|
COFACTOR_4X4_IJ (cofac, m, 0, 1); \
|
|
|
|
d += m[0][1] * cofac; \
|
|
|
|
COFACTOR_4X4_IJ (cofac, m, 0, 2); \
|
|
|
|
d += m[0][2] * cofac; \
|
|
|
|
COFACTOR_4X4_IJ (cofac, m, 0, 3); \
|
|
|
|
d += m[0][3] * cofac; \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ========================================================== */
|
|
|
|
/* compute adjoint of matrix and scale
|
|
|
|
*
|
|
|
|
* Computes adjoint of matrix m, scales it by s, returning a
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SCALE_ADJOINT_3X3(a,s,m) \
|
|
|
|
{ \
|
|
|
|
a[0][0] = (s) * (m[1][1] * m[2][2] - m[1][2] * m[2][1]); \
|
|
|
|
a[1][0] = (s) * (m[1][2] * m[2][0] - m[1][0] * m[2][2]); \
|
|
|
|
a[2][0] = (s) * (m[1][0] * m[2][1] - m[1][1] * m[2][0]); \
|
|
|
|
\
|
|
|
|
a[0][1] = (s) * (m[0][2] * m[2][1] - m[0][1] * m[2][2]); \
|
|
|
|
a[1][1] = (s) * (m[0][0] * m[2][2] - m[0][2] * m[2][0]); \
|
|
|
|
a[2][1] = (s) * (m[0][1] * m[2][0] - m[0][0] * m[2][1]); \
|
|
|
|
\
|
|
|
|
a[0][2] = (s) * (m[0][1] * m[1][2] - m[0][2] * m[1][1]); \
|
|
|
|
a[1][2] = (s) * (m[0][2] * m[1][0] - m[0][0] * m[1][2]); \
|
|
|
|
a[2][2] = (s) * (m[0][0] * m[1][1] - m[0][1] * m[1][0]); \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ========================================================== */
|
|
|
|
/* compute adjoint of matrix and scale
|
|
|
|
*
|
|
|
|
* Computes adjoint of matrix m, scales it by s, returning a
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SCALE_ADJOINT_4X4(a,s,m) \
|
|
|
|
{ \
|
|
|
|
int i,j; \
|
|
|
|
\
|
|
|
|
for (i=0; i<4; i++) { \
|
|
|
|
for (j=0; j<4; j++) { \
|
|
|
|
COFACTOR_4X4_IJ (a[j][i], m, i, j); \
|
|
|
|
a[j][i] *= s; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ========================================================== */
|
|
|
|
/* inverse of matrix
|
|
|
|
*
|
|
|
|
* Compute inverse of matrix a, returning determinant m and
|
|
|
|
* inverse b
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define INVERT_3X3(b,det,a) \
|
|
|
|
{ \
|
|
|
|
double tmp; \
|
|
|
|
DETERMINANT_3X3 (det, a); \
|
|
|
|
tmp = 1.0 / (det); \
|
|
|
|
SCALE_ADJOINT_3X3 (b, tmp, a); \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ========================================================== */
|
|
|
|
/* inverse of matrix
|
|
|
|
*
|
|
|
|
* Compute inverse of matrix a, returning determinant m and
|
|
|
|
* inverse b
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define INVERT_4X4(b,det,a) \
|
|
|
|
{ \
|
|
|
|
double tmp; \
|
|
|
|
DETERMINANT_4X4 (det, a); \
|
|
|
|
tmp = 1.0 / (det); \
|
|
|
|
SCALE_ADJOINT_4X4 (b, tmp, a); \
|
2010-01-24 05:57:43 +00:00
|
|
|
}
|
|
|
|
|
2008-05-05 09:05:07 +00:00
|
|
|
# endif // !POLYMER_C
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2014-11-26 04:39:23 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#endif // !polymer_h_
|