2007-01-29 01:18:16 +00:00
// here lies the GREAT JUSTICE RENDERER
// TODO :
2008-03-30 11:43:24 +00:00
// - CORE STUFF
// o there's also the texture alignment problem Hunter reported (san andreas fault)
2008-03-30 16:08:18 +00:00
// o also sliding doors are still fucked up sometimes (like under the bar in E1L2)
2008-03-30 11:43:24 +00:00
// o shading needs a lot of work
// o remove all the IM matrix crap and write real functions now that it works
// - SPRITES
2009-03-03 21:12:17 +00:00
// o sprite panning
2008-03-30 11:43:24 +00:00
// - SKIES
// o figure a better way to handle ART skies - maybe add symetric caps that would fade to black like a big gem or something wow this is a long column lol ;0)
// - MDSPRITES
// o need full translation and rotation support from CON to attach to game world or tags
//
// the renderer should hopefully be pretty solid after all that
// the rest will be a bliss :)
2007-01-29 01:18:16 +00:00
# ifndef _polymer_h_
# define _polymer_h_
# include "compat.h"
2009-02-05 08:56:59 +00:00
# include "baselayer.h"
2007-01-29 01:18:16 +00:00
# include "build.h"
# include "glbuild.h"
# 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
# include <math.h>
2007-01-29 01:18:16 +00:00
// CVARS
2009-01-16 05:03:12 +00:00
extern int32_t pr_occlusionculling ;
extern int32_t pr_fov ;
extern int32_t pr_billboardingmode ;
extern int32_t pr_verbosity ;
extern int32_t pr_wireframe ;
extern int32_t pr_vbos ;
extern int32_t pr_gpusmoothing ;
2007-01-29 01:18:16 +00:00
2009-01-16 05:03:12 +00:00
extern int32_t glerror ;
2008-03-30 09:16:39 +00:00
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
PR_BIT_NV4X_COMPAT ,
PR_BIT_G8X_COMPAT ,
2008-11-27 22:26:46 +00:00
PR_BIT_ANIM_INTERPOLATION ,
PR_BIT_DIFFUSE_MAP ,
PR_BIT_DIFFUSE_DETAIL_MAP ,
PR_BIT_DIFFUSE_MODULATION ,
2008-11-29 20:16:19 +00:00
PR_BIT_POINT_LIGHT ,
2008-11-27 23:00:57 +00:00
PR_BIT_DIFFUSE_GLOW_MAP ,
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 ;
GLsizei nextframedatastride ;
// 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 ] ;
// PR_BIT_DIFFUSE_DETAIL_MAP
GLuint detailmap ;
GLfloat detailscale [ 2 ] ;
2008-11-27 16:19:24 +00:00
// PR_BIT_DIFFUSE_MODULATION
2008-11-25 10:42:22 +00:00
GLfloat diffusemodulation [ 4 ] ;
2008-11-27 23:00:57 +00:00
// PR_BIT_DIFFUSE_GLOW_MAP
GLuint glowmap ;
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 ;
GLint uniform_frameProgress ;
// PR_BIT_DIFFUSE_MAP
GLint uniform_diffuseMap ;
GLint uniform_diffuseScale ;
// PR_BIT_DIFFUSE_DETAIL_MAP
GLint uniform_detailMap ;
GLint uniform_detailScale ;
2008-11-29 20:16:19 +00:00
// PR_BIT_POINT_LIGHT
2009-01-14 14:13:51 +00:00
GLint uniform_lightCount ;
2008-11-27 23:00:57 +00:00
// PR_BIT_DIFFUSE_GLOW_MAP
GLint uniform_glowMap ;
2008-11-27 22:26:46 +00:00
} _prprograminfo ;
2008-11-29 20:16:19 +00:00
# define PR_INFO_LOG_BUFFER_SIZE 16384
2008-11-27 22:26:46 +00:00
typedef struct s_prprogrambit {
2009-01-16 05:03:12 +00:00
int32_t bit ;
2008-11-27 22:26:46 +00:00
char * vert_def ;
char * vert_prog ;
char * frag_def ;
char * frag_prog ;
} _prprogrambit ;
2009-03-08 20:38:51 +00:00
// LIGHTS
# define PR_MAXLIGHTS 128
# define PR_SM3_MAXLIGHTS 4
# define STR_EXPAND(tok) #tok
# define STR(tok) STR_EXPAND(tok)
typedef enum {
PR_LIGHT_POINT ,
PR_LIGHT_SPOT ,
PR_LIGHT_DIRECTIONAL
} prlighttype ;
typedef struct s_prlight {
int32_t x , y , z , horiz , faderange , range ;
int16_t angle , sector ;
char color [ 3 ] ;
prlighttype type ;
} _prlight ;
2008-11-25 10:42:22 +00:00
// BUILD DATA
2008-05-18 07:35:35 +00:00
typedef struct s_prplane {
2006-09-27 17:55:49 +00:00
// geometry
2008-05-18 07:35:35 +00:00
GLfloat * buffer ;
2009-03-08 20:38:51 +00:00
int32_t vertcount ;
2008-05-18 07:35:35 +00:00
GLuint vbo ;
2006-09-29 21:36:12 +00:00
// attributes
2008-05-18 07:35:35 +00:00
GLdouble plane [ 4 ] ;
2008-11-25 10:42:22 +00:00
_prmaterial material ;
2006-09-27 17:55:49 +00:00
// elements
2008-05-18 07:35:35 +00:00
GLushort * indices ;
GLuint ivbo ;
2009-03-08 20:38:51 +00:00
// lights
char lights [ PR_MAXLIGHTS ] ;
char lightcount ;
2008-05-18 07:35:35 +00:00
} _prplane ;
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 ;
int16_t ceilingstat , floorstat ;
int16_t ceilingpicnum , ceilingheinum ;
int8_t ceilingshade ;
2008-04-02 06:58:26 +00:00
char ceilingpal , ceilingxpanning , ceilingypanning ;
2009-01-16 05:03:12 +00:00
int16_t floorpicnum , floorheinum ;
int8_t floorshade ;
2008-04-02 06:58:26 +00:00
char floorpal , floorxpanning , floorypanning ;
2006-09-27 17:55:49 +00:00
2008-04-02 08:49:21 +00:00
char controlstate ; // 1: up to date, 2: just allocated
2009-01-16 05:03:12 +00:00
uint32_t invalidid ;
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 ;
// stuff
2008-04-03 06:58:36 +00:00
GLfloat * bigportal ;
2008-04-12 08:16:01 +00:00
GLfloat * cap ;
2008-05-24 09:37:09 +00:00
GLuint stuffvbo ;
2008-04-09 07:27:17 +00:00
// build wall data
2009-01-16 05:03:12 +00:00
int16_t cstat , nwallcstat ;
int16_t picnum , overpicnum , nwallpicnum ;
int8_t shade ;
2008-04-02 08:49:21 +00:00
char pal , xrepeat , yrepeat , xpanning , ypanning ;
char nwallxpanning , nwallypanning ;
2006-09-29 21:36:12 +00:00
char underover ;
2009-01-16 05:03:12 +00:00
uint32_t invalidid ;
2008-03-30 19:13:24 +00:00
char controlstate ;
2006-09-29 21:36:12 +00:00
} _prwall ;
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
2008-11-25 10:42:22 +00:00
// PROGRAMS
2008-11-26 08:37:14 +00:00
2007-01-29 01:18:16 +00:00
// CONTROL
2009-01-16 05:03:12 +00:00
extern int32_t updatesectors ;
2007-01-29 01:18:16 +00:00
2006-09-29 21:36:12 +00:00
// EXTERNAL FUNCTIONS
2009-01-16 05:03:12 +00:00
int32_t polymer_init ( void ) ;
2006-09-29 21:36:12 +00:00
void polymer_glinit ( void ) ;
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-01-09 09:29:17 +00:00
void polymer_rotatesprite ( int32_t sx , int32_t sy , int32_t z , int16_t a , int16_t picnum , int8_t dashade , char dapalnum , char dastat , int32_t cx1 , int32_t cy1 , int32_t cx2 , int32_t cy2 ) ;
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 ) ;
2008-11-25 09:07:38 +00:00
void polymer_resetlights ( void ) ;
void polymer_addlight ( _prlight light ) ;
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 ) ;
static void polymer_drawplane ( int16_t sectnum , int16_t wallnum , _prplane * plane , int32_t indicecount ) ;
2008-04-09 07:27:17 +00:00
static void polymer_inb4mirror ( GLfloat * buffer , GLdouble * plane ) ;
2008-04-06 23:35:48 +00:00
static void polymer_animatesprites ( 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 ) ;
2009-01-09 09:29:17 +00:00
static void polymer_drawsector ( int16_t sectnum ) ;
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-01-09 09:29:17 +00:00
static void polymer_buffertoplane ( GLfloat * buffer , GLushort * indices , int32_t indicecount , GLdouble * plane ) ;
2008-04-06 23:35:48 +00:00
static void polymer_crossproduct ( GLfloat * in_a , GLfloat * in_b , GLdouble * out ) ;
2009-01-09 09:29:17 +00:00
static 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-01-16 05:03:12 +00:00
static int32_t polymer_portalinfrustum ( int16_t wallnum , float * frustum ) ;
2009-01-09 09:29:17 +00:00
static void polymer_scansprites ( int16_t sectnum , spritetype * tsprite , int32_t * spritesortcnt ) ;
2006-10-18 03:59:28 +00:00
// SKIES
2008-04-02 09:29:58 +00:00
static void polymer_getsky ( void ) ;
2009-01-09 09:29:17 +00:00
static void polymer_drawsky ( int16_t tilenum ) ;
2008-06-09 09:25:47 +00:00
static void polymer_initartsky ( void ) ;
2009-01-09 09:29:17 +00:00
static void polymer_drawartsky ( int16_t tilenum ) ;
static void polymer_drawartskyquad ( int32_t p1 , int32_t p2 , GLfloat height ) ;
static void polymer_drawskybox ( int16_t tilenum ) ;
2008-06-01 08:58:06 +00:00
// MDSPRITES
static void polymer_drawmdsprite ( spritetype * 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 ) ;
2009-01-09 09:29:17 +00:00
static void polymer_getbuildmaterial ( _prmaterial * material , int16_t tilenum , char pal , int8_t shade ) ;
2009-03-08 20:38:51 +00:00
static int32_t polymer_bindmaterial ( _prmaterial material , char * 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
static void polymer_transformlight ( float * inpos , float * pos , float * matrix ) ;
2009-03-08 20:38:51 +00:00
static int32_t polymer_planeinlight ( _prplane * plane , _prlight * light ) ;
static void polymer_culllight ( char lightindex ) ;
2008-04-02 09:29:58 +00:00
2008-05-05 09:05:07 +00:00
# endif // !POLYMER_C
2007-01-29 01:18:16 +00:00
# endif // !_polymer_h_