Quake-2

Quake 2 GPL Source Release
Log | Files | Refs

ref.h (6252B)


      1 /*
      2 Copyright (C) 1997-2001 Id Software, Inc.
      3 
      4 This program is free software; you can redistribute it and/or
      5 modify it under the terms of the GNU General Public License
      6 as published by the Free Software Foundation; either version 2
      7 of the License, or (at your option) any later version.
      8 
      9 This program is distributed in the hope that it will be useful,
     10 but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
     12 
     13 See the GNU General Public License for more details.
     14 
     15 You should have received a copy of the GNU General Public License
     16 along with this program; if not, write to the Free Software
     17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
     18 
     19 */
     20 
     21 #include "../qcommon/qcommon.h"
     22 
     23 #define	MAX_DLIGHTS		32
     24 #define	MAX_ENTITIES	128
     25 #define	MAX_PARTICLES	4096
     26 #define	MAX_LIGHTSTYLES	256
     27 
     28 #define POWERSUIT_SCALE		4.0F
     29 
     30 #define SHELL_RED_COLOR		0xF2
     31 #define SHELL_GREEN_COLOR	0xD0
     32 #define SHELL_BLUE_COLOR	0xF3
     33 
     34 #define SHELL_RG_COLOR		0xDC
     35 //#define SHELL_RB_COLOR		0x86
     36 #define SHELL_RB_COLOR		0x68
     37 #define SHELL_BG_COLOR		0x78
     38 
     39 //ROGUE
     40 #define SHELL_DOUBLE_COLOR	0xDF // 223
     41 #define	SHELL_HALF_DAM_COLOR	0x90
     42 #define SHELL_CYAN_COLOR	0x72
     43 //ROGUE
     44 
     45 #define SHELL_WHITE_COLOR	0xD7
     46 
     47 typedef struct entity_s
     48 {
     49 	struct model_s		*model;			// opaque type outside refresh
     50 	float				angles[3];
     51 
     52 	/*
     53 	** most recent data
     54 	*/
     55 	float				origin[3];		// also used as RF_BEAM's "from"
     56 	int					frame;			// also used as RF_BEAM's diameter
     57 
     58 	/*
     59 	** previous data for lerping
     60 	*/
     61 	float				oldorigin[3];	// also used as RF_BEAM's "to"
     62 	int					oldframe;
     63 
     64 	/*
     65 	** misc
     66 	*/
     67 	float	backlerp;				// 0.0 = current, 1.0 = old
     68 	int		skinnum;				// also used as RF_BEAM's palette index
     69 
     70 	int		lightstyle;				// for flashing entities
     71 	float	alpha;					// ignore if RF_TRANSLUCENT isn't set
     72 
     73 	struct image_s	*skin;			// NULL for inline skin
     74 	int		flags;
     75 
     76 } entity_t;
     77 
     78 #define ENTITY_FLAGS  68
     79 
     80 typedef struct
     81 {
     82 	vec3_t	origin;
     83 	vec3_t	color;
     84 	float	intensity;
     85 } dlight_t;
     86 
     87 typedef struct
     88 {
     89 	vec3_t	origin;
     90 	int		color;
     91 	float	alpha;
     92 } particle_t;
     93 
     94 typedef struct
     95 {
     96 	float		rgb[3];			// 0.0 - 2.0
     97 	float		white;			// highest of rgb
     98 } lightstyle_t;
     99 
    100 typedef struct
    101 {
    102 	int			x, y, width, height;// in virtual screen coordinates
    103 	float		fov_x, fov_y;
    104 	float		vieworg[3];
    105 	float		viewangles[3];
    106 	float		blend[4];			// rgba 0-1 full screen blend
    107 	float		time;				// time is uesed to auto animate
    108 	int			rdflags;			// RDF_UNDERWATER, etc
    109 
    110 	byte		*areabits;			// if not NULL, only areas with set bits will be drawn
    111 
    112 	lightstyle_t	*lightstyles;	// [MAX_LIGHTSTYLES]
    113 
    114 	int			num_entities;
    115 	entity_t	*entities;
    116 
    117 	int			num_dlights;
    118 	dlight_t	*dlights;
    119 
    120 	int			num_particles;
    121 	particle_t	*particles;
    122 } refdef_t;
    123 
    124 
    125 
    126 #define	API_VERSION		3
    127 
    128 //
    129 // these are the functions exported by the refresh module
    130 //
    131 typedef struct
    132 {
    133 	// if api_version is different, the dll cannot be used
    134 	int		api_version;
    135 
    136 	// called when the library is loaded
    137 	qboolean	(*Init) ( void *hinstance, void *wndproc );
    138 
    139 	// called before the library is unloaded
    140 	void	(*Shutdown) (void);
    141 
    142 	// All data that will be used in a level should be
    143 	// registered before rendering any frames to prevent disk hits,
    144 	// but they can still be registered at a later time
    145 	// if necessary.
    146 	//
    147 	// EndRegistration will free any remaining data that wasn't registered.
    148 	// Any model_s or skin_s pointers from before the BeginRegistration
    149 	// are no longer valid after EndRegistration.
    150 	//
    151 	// Skins and images need to be differentiated, because skins
    152 	// are flood filled to eliminate mip map edge errors, and pics have
    153 	// an implicit "pics/" prepended to the name. (a pic name that starts with a
    154 	// slash will not use the "pics/" prefix or the ".pcx" postfix)
    155 	void	(*BeginRegistration) (char *map);
    156 	struct model_s *(*RegisterModel) (char *name);
    157 	struct image_s *(*RegisterSkin) (char *name);
    158 	struct image_s *(*RegisterPic) (char *name);
    159 	void	(*SetSky) (char *name, float rotate, vec3_t axis);
    160 	void	(*EndRegistration) (void);
    161 
    162 	void	(*RenderFrame) (refdef_t *fd);
    163 
    164 	void	(*DrawGetPicSize) (int *w, int *h, char *name);	// will return 0 0 if not found
    165 	void	(*DrawPic) (int x, int y, char *name);
    166 	void	(*DrawStretchPic) (int x, int y, int w, int h, char *name);
    167 	void	(*DrawChar) (int x, int y, int c);
    168 	void	(*DrawTileClear) (int x, int y, int w, int h, char *name);
    169 	void	(*DrawFill) (int x, int y, int w, int h, int c);
    170 	void	(*DrawFadeScreen) (void);
    171 
    172 	// Draw images for cinematic rendering (which can have a different palette). Note that calls
    173 	void	(*DrawStretchRaw) (int x, int y, int w, int h, int cols, int rows, byte *data);
    174 
    175 	/*
    176 	** video mode and refresh state management entry points
    177 	*/
    178 	void	(*CinematicSetPalette)( const unsigned char *palette);	// NULL = game palette
    179 	void	(*BeginFrame)( float camera_separation );
    180 	void	(*EndFrame) (void);
    181 
    182 	void	(*AppActivate)( qboolean activate );
    183 
    184 } refexport_t;
    185 
    186 //
    187 // these are the functions imported by the refresh module
    188 //
    189 typedef struct
    190 {
    191 	void	(*Sys_Error) (int err_level, char *str, ...);
    192 
    193 	void	(*Cmd_AddCommand) (char *name, void(*cmd)(void));
    194 	void	(*Cmd_RemoveCommand) (char *name);
    195 	int		(*Cmd_Argc) (void);
    196 	char	*(*Cmd_Argv) (int i);
    197 	void	(*Cmd_ExecuteText) (int exec_when, char *text);
    198 
    199 	void	(*Con_Printf) (int print_level, char *str, ...);
    200 
    201 	// files will be memory mapped read only
    202 	// the returned buffer may be part of a larger pak file,
    203 	// or a discrete file from anywhere in the quake search path
    204 	// a -1 return means the file does not exist
    205 	// NULL can be passed for buf to just determine existance
    206 	int		(*FS_LoadFile) (char *name, void **buf);
    207 	void	(*FS_FreeFile) (void *buf);
    208 
    209 	// gamedir will be the current directory that generated
    210 	// files should be stored to, ie: "f:\quake\id1"
    211 	char	*(*FS_Gamedir) (void);
    212 
    213 	cvar_t	*(*Cvar_Get) (char *name, char *value, int flags);
    214 	cvar_t	*(*Cvar_Set)( char *name, char *value );
    215 	void	 (*Cvar_SetValue)( char *name, float value );
    216 
    217 	qboolean	(*Vid_GetModeInfo)( int *width, int *height, int mode );
    218 	void		(*Vid_MenuInit)( void );
    219 	void		(*Vid_NewWindow)( int width, int height );
    220 } refimport_t;
    221 
    222 
    223 // this is the only function actually exported at the linker level
    224 typedef	refexport_t	(*GetRefAPI_t) (refimport_t);