2004-08-23 00:15:46 +00:00
|
|
|
//These are defined later in the source tree. This file should probably be moved to a later spot.
|
|
|
|
struct progfuncs_s;
|
|
|
|
struct globalvars_s;
|
|
|
|
struct texture_s;
|
2011-01-23 03:51:27 +00:00
|
|
|
struct texnums_s;
|
|
|
|
struct vbo_s;
|
|
|
|
struct mesh_s;
|
|
|
|
struct batch_s;
|
|
|
|
struct entity_s;
|
2011-10-27 16:42:53 +00:00
|
|
|
struct dlight_s;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2008-12-23 02:55:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef HALFLIFEMODELS
|
|
|
|
#define MAX_BONE_CONTROLLERS 5
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define FST_BASE 0 //base frames
|
|
|
|
#define FS_REG 1 //regular frames
|
|
|
|
#define FS_COUNT 2 //regular frames
|
|
|
|
typedef struct {
|
|
|
|
struct {
|
|
|
|
int frame[2];
|
|
|
|
float frametime[2];
|
|
|
|
float lerpfrac;
|
|
|
|
|
|
|
|
#ifdef HALFLIFEMODELS
|
|
|
|
float subblendfrac; //hl models are weird
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int endbone;
|
|
|
|
} g[2];
|
|
|
|
|
|
|
|
float *bonestate;
|
|
|
|
int bonecount;
|
|
|
|
|
|
|
|
#ifdef HALFLIFEMODELS
|
|
|
|
float bonecontrols[MAX_BONE_CONTROLLERS]; //hl special bone controllers
|
|
|
|
#endif
|
|
|
|
} framestate_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
//function prototypes
|
|
|
|
|
|
|
|
#if defined(SERVERONLY)
|
|
|
|
#define qrenderer QR_NONE
|
2005-07-16 00:53:08 +00:00
|
|
|
#define FNC(n) (n) //FNC is defined as 'pointer if client build, direct if dedicated server'
|
2009-07-06 07:45:46 +00:00
|
|
|
|
|
|
|
#define Mod_SkinForName Mod_SkinNumForName
|
|
|
|
#define Mod_FrameForName Mod_FrameNumForName
|
|
|
|
#define Mod_GetFrameDuration Mod_FrameDuration
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
#else
|
|
|
|
#define FNC(n) (*n)
|
|
|
|
extern r_qrenderer_t qrenderer;
|
|
|
|
extern char *q_renderername;
|
|
|
|
|
2011-03-31 01:14:01 +00:00
|
|
|
mpic_t *R2D_SafeCachePic (char *path);
|
|
|
|
mpic_t *R2D_SafePicFromWad (char *name);
|
2011-03-31 19:46:26 +00:00
|
|
|
void R2D_DrawCrosshair (void);
|
2011-03-31 01:14:01 +00:00
|
|
|
void R2D_ScalePic (int x, int y, int width, int height, mpic_t *pic);
|
|
|
|
void R2D_SubPic(int x, int y, int width, int height, mpic_t *pic, int srcx, int srcy, int srcwidth, int srcheight);
|
2011-03-31 11:00:23 +00:00
|
|
|
void R2D_TransPicTranslate (int x, int y, int width, int height, qbyte *pic, qbyte *translation);
|
2011-03-31 01:14:01 +00:00
|
|
|
void R2D_TileClear (int x, int y, int w, int h);
|
|
|
|
void R2D_FadeScreen (void);
|
|
|
|
|
|
|
|
void R2D_ConsoleBackground (int firstline, int lastline, qboolean forceopaque);
|
|
|
|
void R2D_EditorBackground (void);
|
|
|
|
|
|
|
|
void R2D_Image(float x, float y, float w, float h, float s1, float t1, float s2, float t2, mpic_t *pic);
|
|
|
|
|
|
|
|
void R2D_ImageColours(float r, float g, float b, float a);
|
|
|
|
void R2D_ImagePaletteColour(unsigned int i, float a);
|
|
|
|
void R2D_FillBlock(int x, int y, int w, int h);
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
extern void (*Draw_Init) (void);
|
2008-06-01 22:06:22 +00:00
|
|
|
extern void (*Draw_TinyCharacter) (int x, int y, unsigned int num);
|
2004-11-23 01:10:10 +00:00
|
|
|
extern qboolean (*Draw_IsCached) (char *picname); //can be null
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
extern void (*R_Init) (void);
|
|
|
|
extern void (*R_DeInit) (void);
|
|
|
|
extern void (*R_RenderView) (void); // must set r_refdef first
|
|
|
|
|
|
|
|
extern void (*R_NewMap) (void);
|
|
|
|
extern void (*R_PreNewMap) (void);
|
|
|
|
extern int (*R_LightPoint) (vec3_t point);
|
|
|
|
|
|
|
|
extern void (*R_AddStain) (vec3_t org, float red, float green, float blue, float radius);
|
|
|
|
extern void (*R_LessenStains) (void);
|
|
|
|
|
|
|
|
extern qboolean (*VID_Init) (rendererstate_t *info, unsigned char *palette);
|
|
|
|
extern void (*VID_DeInit) (void);
|
|
|
|
extern void (*VID_SetPalette) (unsigned char *palette);
|
|
|
|
extern void (*VID_ShiftPalette) (unsigned char *palette);
|
2004-11-23 01:10:10 +00:00
|
|
|
extern char *(*VID_GetRGBInfo) (int prepad, int *truevidwidth, int *truevidheight);
|
|
|
|
extern void (*VID_SetWindowCaption) (char *msg);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
extern void SCR_Init (void);
|
|
|
|
extern void SCR_DeInit (void);
|
|
|
|
extern void (*SCR_UpdateScreen) (void);
|
|
|
|
extern void SCR_BeginLoadingPlaque (void);
|
|
|
|
extern void SCR_EndLoadingPlaque (void);
|
|
|
|
extern void SCR_DrawConsole (qboolean noback);
|
|
|
|
extern void SCR_SetUpToDrawConsole (void);
|
|
|
|
extern void SCR_EraseCenterString (void);
|
2009-04-19 00:50:42 +00:00
|
|
|
extern void SCR_CenterPrint (int pnum, char *str, qboolean skipgamecode);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
void R_DrawTextField(int x, int y, int w, int h, char *text, unsigned int defaultmask, unsigned int fieldflags);
|
|
|
|
#define CPRINT_BALIGN (1<<0) //B
|
|
|
|
#define CPRINT_TALIGN (1<<1) //T
|
|
|
|
#define CPRINT_LALIGN (1<<2) //L
|
|
|
|
#define CPRINT_RALIGN (1<<3) //R
|
|
|
|
#define CPRINT_BACKGROUND (1<<4) //P
|
|
|
|
|
|
|
|
#define CPRINT_OBITUARTY (1<<16) //O (show at 2/3rds from top)
|
|
|
|
#define CPRINT_PERSIST (1<<17) //P (doesn't time out)
|
|
|
|
#define CPRINT_TYPEWRITER (1<<18) // (char at a time)
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
extern void FNC(Mod_Init) (void);
|
|
|
|
extern void FNC(Mod_ClearAll) (void);
|
|
|
|
extern struct model_s *FNC(Mod_ForName) (char *name, qboolean crash);
|
|
|
|
extern struct model_s *FNC(Mod_FindName) (char *name);
|
|
|
|
extern void *FNC(Mod_Extradata) (struct model_s *mod); // handles caching
|
|
|
|
extern void FNC(Mod_TouchModel) (char *name);
|
|
|
|
|
|
|
|
extern void FNC(Mod_NowLoadExternal) (void);
|
|
|
|
|
|
|
|
extern void FNC(Mod_Think) (void);
|
2005-08-03 23:14:59 +00:00
|
|
|
extern int FNC(Mod_SkinForName) (struct model_s *model, char *name);
|
2009-04-01 22:03:56 +00:00
|
|
|
extern int FNC(Mod_FrameForName) (struct model_s *model, char *name);
|
2009-07-06 01:20:20 +00:00
|
|
|
extern float FNC(Mod_GetFrameDuration) (struct model_s *model, int framenum);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
#undef FNC
|
|
|
|
|
2008-12-23 02:55:20 +00:00
|
|
|
extern qboolean Mod_GetTag (struct model_s *model, int tagnum, framestate_t *framestate, float *transforms);
|
2007-05-25 23:03:49 +00:00
|
|
|
extern int Mod_TagNumForName (struct model_s *model, char *name);
|
|
|
|
|
2008-12-23 02:55:20 +00:00
|
|
|
int Mod_GetNumBones(struct model_s *model, qboolean allowtags);
|
2009-04-19 00:50:42 +00:00
|
|
|
int Mod_GetBoneRelations(struct model_s *model, int firstbone, int lastbone, framestate_t *fstate, float *result);
|
2008-12-23 02:55:20 +00:00
|
|
|
int Mod_GetBoneParent(struct model_s *model, int bonenum);
|
|
|
|
char *Mod_GetBoneName(struct model_s *model, int bonenum);
|
|
|
|
|
2010-07-11 10:53:13 +00:00
|
|
|
void Draw_FunString(int x, int y, const void *str);
|
|
|
|
void Draw_AltFunString(int x, int y, const void *str);
|
|
|
|
void Draw_FunStringWidth(int x, int y, const void *str, int width);
|
2005-01-24 23:47:32 +00:00
|
|
|
|
2011-10-27 15:46:36 +00:00
|
|
|
int r_regsequence;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
#ifdef SERVERONLY
|
|
|
|
#define Mod_Q1LeafPVS Mod_LeafPVS
|
2005-09-08 01:47:48 +00:00
|
|
|
// qbyte *Mod_LeafPVS (struct mleaf_s *leaf, struct model_s *model, qbyte *buffer);
|
2004-08-23 00:15:46 +00:00
|
|
|
#endif
|
2005-06-22 17:10:13 +00:00
|
|
|
|
2011-10-27 15:46:36 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int regsequence;
|
|
|
|
} texcom_t;
|
|
|
|
struct texid_s
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
unsigned int num;
|
2010-10-02 02:25:39 +00:00
|
|
|
#ifdef D3DQUAKE
|
2011-10-27 15:46:36 +00:00
|
|
|
void *ptr;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
texcom_t *ref;
|
|
|
|
};
|
|
|
|
#if 1
|
|
|
|
typedef struct texid_s texid_t;
|
|
|
|
#define texid_tf texid_t
|
|
|
|
#define TEXASSIGN(d,s) d=s
|
|
|
|
#define TEXASSIGNF(d,s) d=s
|
|
|
|
#define TEXVALID(t) ((t).ref!=NULL)
|
|
|
|
#else
|
|
|
|
typedef struct texid_s texid_t[1];
|
|
|
|
typedef struct texid_s texid_tf;
|
|
|
|
#define TEXASSIGN(d,s) memcpy(&d,&s,sizeof(d))
|
|
|
|
#define TEXASSIGNF(d,s) memcpy(&d,&s,sizeof(d))
|
|
|
|
#define TEXVALID(t) 1
|
2010-10-02 02:25:39 +00:00
|
|
|
#endif
|
2011-01-04 02:56:16 +00:00
|
|
|
typedef enum uploadfmt uploadfmt_t;
|
2011-01-29 19:53:38 +00:00
|
|
|
//not all modes accept meshes - STENCIL(intentional) and DEPTHONLY(not implemented)
|
|
|
|
typedef enum backendmode_e
|
|
|
|
{
|
|
|
|
BEM_STANDARD, //regular mode to draw surfaces akin to q3 (aka: legacy mode). lightmaps+delux+ambient
|
|
|
|
BEM_DEPTHONLY, //just a quick depth pass. textures used only for alpha test (shadowmaps).
|
|
|
|
BEM_STENCIL, //used for drawing shadow volumes to the stencil buffer.
|
|
|
|
BEM_DEPTHDARK, //a quick depth pass. textures used only for alpha test. additive textures still shown as normal.
|
2011-09-03 03:49:43 +00:00
|
|
|
BEM_DEPTHNORM, //all opaque stuff drawn using 'depthnorm' shader
|
2011-02-25 04:22:14 +00:00
|
|
|
BEM_LIGHT, //we have a valid light
|
2011-01-29 19:53:38 +00:00
|
|
|
BEM_SMAPLIGHTSPOT, //we have a spot light using a shadowmap
|
2011-02-25 04:22:14 +00:00
|
|
|
BEM_SMAPLIGHT, //we have a light using a shadowmap
|
|
|
|
BEM_FOG //drawing a fog volume
|
2011-01-29 19:53:38 +00:00
|
|
|
} backendmode_t;
|
2005-06-22 17:10:13 +00:00
|
|
|
|
2010-02-06 01:25:04 +00:00
|
|
|
typedef struct rendererinfo_s {
|
2005-06-22 17:10:13 +00:00
|
|
|
char *description;
|
|
|
|
char *name[4];
|
|
|
|
r_qrenderer_t rtype;
|
|
|
|
|
|
|
|
void (*Draw_Init) (void);
|
2009-11-04 21:16:50 +00:00
|
|
|
void (*Draw_Shutdown) (void);
|
2005-06-22 17:10:13 +00:00
|
|
|
|
2011-10-27 15:46:36 +00:00
|
|
|
texid_tf (*IMG_LoadTexture) (char *identifier, int width, int height, uploadfmt_t fmt, void *data, unsigned int flags);
|
|
|
|
texid_tf (*IMG_LoadTexture8Pal24) (char *identifier, int width, int height, qbyte *data, qbyte *palette24, unsigned int flags);
|
|
|
|
texid_tf (*IMG_LoadTexture8Pal32) (char *identifier, int width, int height, qbyte *data, qbyte *palette32, unsigned int flags);
|
|
|
|
texid_tf (*IMG_LoadCompressed) (char *name);
|
|
|
|
texid_tf (*IMG_FindTexture) (char *identifier);
|
|
|
|
texid_tf (*IMG_AllocNewTexture) (char *identifier, int w, int h);
|
2011-01-04 02:56:16 +00:00
|
|
|
void (*IMG_Upload) (texid_t tex, char *name, uploadfmt_t fmt, void *data, void *palette, int width, int height, unsigned int flags);
|
2010-10-02 02:25:39 +00:00
|
|
|
void (*IMG_DestroyTexture) (texid_t tex);
|
|
|
|
|
2005-06-22 17:10:13 +00:00
|
|
|
void (*R_Init) (void);
|
|
|
|
void (*R_DeInit) (void);
|
|
|
|
void (*R_RenderView) (void); // must set r_refdef first
|
|
|
|
|
|
|
|
void (*R_NewMap) (void);
|
|
|
|
void (*R_PreNewMap) (void);
|
|
|
|
int (*R_LightPoint) (vec3_t point);
|
|
|
|
|
|
|
|
void (*R_AddStain) (vec3_t org, float red, float green, float blue, float radius);
|
|
|
|
void (*R_LessenStains) (void);
|
|
|
|
|
|
|
|
void (*Mod_Init) (void);
|
2011-02-02 00:41:01 +00:00
|
|
|
void (*Mod_Shutdown) (void);
|
2005-06-22 17:10:13 +00:00
|
|
|
void (*Mod_ClearAll) (void);
|
|
|
|
struct model_s *(*Mod_ForName) (char *name, qboolean crash);
|
|
|
|
struct model_s *(*Mod_FindName) (char *name);
|
|
|
|
void *(*Mod_Extradata) (struct model_s *mod); // handles caching
|
|
|
|
void (*Mod_TouchModel) (char *name);
|
|
|
|
|
|
|
|
void (*Mod_NowLoadExternal) (void);
|
|
|
|
void (*Mod_Think) (void);
|
2008-12-23 02:55:20 +00:00
|
|
|
qboolean (*Mod_GetTag) (struct model_s *model, int tagnum, framestate_t *fstate, float *result);
|
2005-06-22 17:10:13 +00:00
|
|
|
int (*Mod_TagNumForName) (struct model_s *model, char *name);
|
2005-08-03 23:14:59 +00:00
|
|
|
int (*Mod_SkinForName) (struct model_s *model, char *name);
|
2009-04-01 22:03:56 +00:00
|
|
|
int (*Mod_FrameForName) (struct model_s *model, char *name);
|
2009-07-06 01:20:20 +00:00
|
|
|
float (*Mod_GetFrameDuration) (struct model_s *model, int frame);
|
2005-06-22 17:10:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
qboolean (*VID_Init) (rendererstate_t *info, unsigned char *palette);
|
|
|
|
void (*VID_DeInit) (void);
|
|
|
|
void (*VID_SetPalette) (unsigned char *palette);
|
|
|
|
void (*VID_ShiftPalette) (unsigned char *palette);
|
|
|
|
char *(*VID_GetRGBInfo) (int prepad, int *truevidwidth, int *truevidheight);
|
|
|
|
void (*VID_SetWindowCaption) (char *msg);
|
|
|
|
|
|
|
|
void (*SCR_UpdateScreen) (void);
|
|
|
|
|
2011-01-04 02:56:16 +00:00
|
|
|
|
|
|
|
//Select the current render mode and modifier flags
|
2011-04-20 23:34:13 +00:00
|
|
|
void (*BE_SelectMode)(backendmode_t mode);
|
2011-01-04 02:56:16 +00:00
|
|
|
/*Draws an entire mesh list from a VBO. vbo can be null, in which case the chain may be drawn without batching.
|
|
|
|
Rules for using a list: Every mesh must be part of the same VBO, shader, lightmap, and must have the same pointers set*/
|
2011-04-20 23:34:13 +00:00
|
|
|
void (*BE_DrawMesh_List)(shader_t *shader, int nummeshes, struct mesh_s **mesh, struct vbo_s *vbo, struct texnums_s *texnums, unsigned int be_flags);
|
|
|
|
void (*BE_DrawMesh_Single)(shader_t *shader, struct mesh_s *meshchain, struct vbo_s *vbo, struct texnums_s *texnums, unsigned int be_flags);
|
2011-01-04 02:56:16 +00:00
|
|
|
void (*BE_SubmitBatch)(struct batch_s *batch);
|
|
|
|
struct batch_s *(*BE_GetTempBatch)(void);
|
|
|
|
//Asks the backend to invoke DrawMeshChain for each surface, and to upload lightmaps as required
|
|
|
|
void (*BE_DrawWorld) (qbyte *vis);
|
|
|
|
//called at init, force the display to the right defaults etc
|
|
|
|
void (*BE_Init)(void);
|
|
|
|
//Generates an optimised VBO, one for each texture on the map
|
|
|
|
void (*BE_GenBrushModelVBO)(struct model_s *mod);
|
|
|
|
//Destroys the given vbo
|
|
|
|
void (*BE_ClearVBO)(struct vbo_s *vbo);
|
|
|
|
//Uploads all modified lightmaps
|
|
|
|
void (*BE_UploadAllLightmaps)(void);
|
|
|
|
void (*BE_SelectEntity)(struct entity_s *ent);
|
2011-10-27 15:46:36 +00:00
|
|
|
void (*BE_SelectDLight)(struct dlight_s *dl, vec3_t colour);
|
2011-01-04 02:56:16 +00:00
|
|
|
/*check to see if an ent should be drawn for the selected light*/
|
|
|
|
qboolean (*BE_LightCullModel)(vec3_t org, struct model_s *model);
|
|
|
|
|
2005-06-22 17:10:13 +00:00
|
|
|
char *alignment;
|
|
|
|
} rendererinfo_t;
|
2010-10-02 02:25:39 +00:00
|
|
|
|
|
|
|
#define rf currentrendererstate.renderer
|
|
|
|
|
|
|
|
#define R_LoadTexture rf->IMG_LoadTexture
|
|
|
|
#define R_LoadTexture8Pal24 rf->IMG_LoadTexture8Pal24
|
|
|
|
#define R_LoadTexture8Pal32 rf->IMG_LoadTexture8Pal32
|
|
|
|
#define R_LoadCompressed rf->IMG_LoadCompressed
|
|
|
|
#define R_FindTexture rf->IMG_FindTexture
|
|
|
|
#define R_AllocNewTexture rf->IMG_AllocNewTexture
|
|
|
|
#define R_Upload rf->IMG_Upload
|
|
|
|
#define R_DestroyTexture rf->IMG_DestroyTexture
|
2011-01-04 02:56:16 +00:00
|
|
|
|
|
|
|
#define BE_Init rf->BE_Init
|
|
|
|
#define BE_SelectMode rf->BE_SelectMode
|
|
|
|
#define BE_GenBrushModelVBO rf->BE_GenBrushModelVBO
|
|
|
|
#define BE_ClearVBO rf->BE_ClearVBO
|
|
|
|
#define BE_UploadAllLightmaps rf->BE_UploadAllLightmaps
|
|
|
|
#define BE_LightCullModel rf->BE_LightCullModel
|
|
|
|
#define BE_SelectEntity rf->BE_SelectEntity
|
2011-10-27 15:46:36 +00:00
|
|
|
#define BE_SelectDLight rf->BE_SelectDLight
|
2011-01-04 02:56:16 +00:00
|
|
|
#define BE_GetTempBatch rf->BE_GetTempBatch
|
|
|
|
#define BE_SubmitBatch rf->BE_SubmitBatch
|
|
|
|
#define BE_DrawMesh_List rf->BE_DrawMesh_List
|
|
|
|
#define BE_DrawMesh_Single rf->BE_DrawMesh_Single
|
|
|
|
#define BE_SubimtMeshes rf->BE_SubimtMeshes
|
2011-01-29 19:53:38 +00:00
|
|
|
#define BE_DrawWorld rf->BE_DrawWorld
|