icculus quake2 doxygen  1.0 dev
ref.h
Go to the documentation of this file.
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 #ifndef __REF_H
21 #define __REF_H
22 
23 #include "../qcommon/qcommon.h"
24 
25 #define MAX_DLIGHTS 32
26 #define MAX_ENTITIES 128
27 #define MAX_PARTICLES 4096
28 #define MAX_LIGHTSTYLES 256
29 
30 #define POWERSUIT_SCALE 4.0F
31 
32 #define SHELL_RED_COLOR 0xF2
33 #define SHELL_GREEN_COLOR 0xD0
34 #define SHELL_BLUE_COLOR 0xF3
35 
36 #define SHELL_RG_COLOR 0xDC
37 //#define SHELL_RB_COLOR 0x86
38 #define SHELL_RB_COLOR 0x68
39 #define SHELL_BG_COLOR 0x78
40 
41 //ROGUE
42 #define SHELL_DOUBLE_COLOR 0xDF // 223
43 #define SHELL_HALF_DAM_COLOR 0x90
44 #define SHELL_CYAN_COLOR 0x72
45 //ROGUE
46 
47 #define SHELL_WHITE_COLOR 0xD7
48 
49 typedef struct entity_s
50 {
51  struct model_s *model; // opaque type outside refresh
52  float angles[3];
53 
54  /*
55  ** most recent data
56  */
57  float origin[3]; // also used as RF_BEAM's "from"
58  int frame; // also used as RF_BEAM's diameter
59 
60  /*
61  ** previous data for lerping
62  */
63  float oldorigin[3]; // also used as RF_BEAM's "to"
64  int oldframe;
65 
66  /*
67  ** misc
68  */
69  float backlerp; // 0.0 = current, 1.0 = old
70  int skinnum; // also used as RF_BEAM's palette index
71 
72  int lightstyle; // for flashing entities
73  float alpha; // ignore if RF_TRANSLUCENT isn't set
74 
75  struct image_s *skin; // NULL for inline skin
76  int flags;
77 #ifdef QMAX
78  int renderfx;
79 #endif
80 } entity_t;
81 
82 #define ENTITY_FLAGS 68
83 
84 typedef struct
85 {
86 #ifdef QMAX
87  qboolean spotlight;
88  vec3_t direction;
89 #endif
90 
93  float intensity;
94 } dlight_t;
95 
96 typedef struct
97 {
99  int color;
100  float alpha;
101 #ifdef QMAX
102  vec3_t angle;
103  float size;
104  int flags;
105 
106  float red;
107  float green;
108  float blue;
109 
110  int image;
111 #endif
112 } particle_t;
113 
114 typedef struct
115 {
116  float rgb[3]; // 0.0 - 2.0
117  float white; // highest of rgb
118 } lightstyle_t;
119 
120 typedef struct
121 {
122  int x, y, width, height;// in virtual screen coordinates
123  float fov_x, fov_y;
124  float vieworg[3];
125  float viewangles[3];
126  float blend[4]; // rgba 0-1 full screen blend
127  float time; // time is uesed to auto animate
128  int rdflags; // RDF_UNDERWATER, etc
129 
130  byte *areabits; // if not NULL, only areas with set bits will be drawn
131 
132  lightstyle_t *lightstyles; // [MAX_LIGHTSTYLES]
133 
136 
139 
142 } refdef_t;
143 
144 
145 
146 #define API_VERSION 3
147 
148 //
149 // these are the functions exported by the refresh module
150 //
151 typedef struct
152 {
153  // if api_version is different, the dll cannot be used
155 
156  // called when the library is loaded
157  int (*Init) ( void *hinstance, void *wndproc );
158 
159  // called before the library is unloaded
160  void (*Shutdown) (void);
161 
162  // All data that will be used in a level should be
163  // registered before rendering any frames to prevent disk hits,
164  // but they can still be registered at a later time
165  // if necessary.
166  //
167  // EndRegistration will free any remaining data that wasn't registered.
168  // Any model_s or skin_s pointers from before the BeginRegistration
169  // are no longer valid after EndRegistration.
170  //
171  // Skins and images need to be differentiated, because skins
172  // are flood filled to eliminate mip map edge errors, and pics have
173  // an implicit "pics/" prepended to the name. (a pic name that starts with a
174  // slash will not use the "pics/" prefix or the ".pcx" postfix)
175  void (*BeginRegistration) (char *map);
176  struct model_s *(*RegisterModel) (char *name);
177  struct image_s *(*RegisterSkin) (char *name);
178  struct image_s *(*RegisterPic) (char *name);
179  void (*SetSky) (char *name, float rotate, vec3_t axis);
180  void (*EndRegistration) (void);
181 
182  void (*RenderFrame) (refdef_t *fd);
183 
184 #ifdef QMAX
185  void (*AddStain) (vec3_t org, float intensity, float r, float g, float b);
186  void (*SetParticlePicture) (int num, char *name);
187  void (*DrawScaledPic) (int x, int y, float scale, float alpha, char *name);
188  float (*CharMap_Scale) (void);
189  void (*DrawStretchPic) (int x, int y, int w, int h, char *name, float alpha);
190  void (*DrawChar) (int x, int y, int c, int alpha);
191 #else
192  void (*DrawStretchPic) (int x, int y, int w, int h, char *name);
193  void (*DrawChar) (int x, int y, int c);
194 #endif
195  void (*DrawGetPicSize) (int *w, int *h, char *name); // will return 0 0 if not found
196  void (*DrawPic) (int x, int y, char *name);
197  void (*DrawTileClear) (int x, int y, int w, int h, char *name);
198  void (*DrawFill) (int x, int y, int w, int h, int c);
199  void (*DrawFadeScreen) (void);
200 
201  // Draw images for cinematic rendering (which can have a different palette). Note that calls
202  void (*DrawStretchRaw) (int x, int y, int w, int h, int cols, int rows, byte *data);
203 
204  /*
205  ** video mode and refresh state management entry points
206  */
207  void (*CinematicSetPalette)( const unsigned char *palette); // NULL = game palette
208  void (*BeginFrame)( float camera_separation );
209  void (*EndFrame) (void);
210 
211  void (*AppActivate)( qboolean activate );
212 
213 } refexport_t;
214 
215 //
216 // these are the functions imported by the refresh module
217 //
218 typedef struct
219 {
220  void (*Sys_Error) (int err_level, char *str, ...);
221 
222  void (*Cmd_AddCommand) (char *name, void(*cmd)(void));
225  char *(*Cmd_Argv) (int i);
226  void (*Cmd_ExecuteText) (int exec_when, char *text);
227 
228  void (*Con_Printf) (int print_level, char *str, ...);
229 
230  // files will be memory mapped read only
231  // the returned buffer may be part of a larger pak file,
232  // or a discrete file from anywhere in the quake search path
233  // a -1 return means the file does not exist
234  // NULL can be passed for buf to just determine existance
235  int (*FS_LoadFile) (char *name, void **buf);
236  void (*FS_FreeFile) (void *buf);
237 
238  // gamedir will be the current directory that generated
239  // files should be stored to, ie: "f:\quake\id1"
240  char *(*FS_Gamedir) (void);
241 
242  cvar_t *(*Cvar_Get) (char *name, char *value, int flags);
243  cvar_t *(*Cvar_Set)( char *name, char *value );
244  void (*Cvar_SetValue)( char *name, float value );
245 
246  qboolean (*Vid_GetModeInfo)( int *width, int *height, int mode );
247  void (*Vid_MenuInit)( void );
248  void (*Vid_NewWindow)( int width, int height );
249 
250 #ifdef QMAX
251  void (*SetParticlePics) (void);
252 #endif
253 } refimport_t;
254 
255 #ifdef QMAX
256 #define DIV254BY255 (0.9960784313725490196078431372549f)
257 #define DIV255 (0.003921568627450980392156862745098f)
258 #define DIV256 (0.00390625f)
259 #define DIV512 (0.001953125f)
260 #define TWOTHIRDS (0.666666666666666666666666666666666666666f)
261 
262 typedef struct
263 {
264  vec3_t origin;
265  vec3_t color;
266  float intensity;
267 } dstain_t;
268 #endif
269 
270 
271 // this is the only function actually exported at the linker level
273 
274 #endif // __REF_H
height
GLsizei height
Definition: qgl_win.c:69
value
GLfloat value
Definition: qgl_win.c:63
entity_s::skin
struct image_s * skin
Definition: ref.h:75
entity_s::origin
float origin[3]
Definition: ref.h:57
entity_s::model
struct model_s * model
Definition: ref.h:51
refdef_t
Definition: ref.h:120
int
CONST PIXELFORMATDESCRIPTOR int
Definition: qgl_win.c:35
green
GLfloat green
Definition: qgl_win.c:74
refdef_t::areabits
byte * areabits
Definition: ref.h:130
Sys_Error
void Sys_Error(char *error,...)
Definition: sys_win.c:67
qboolean
qboolean
Definition: q_shared.h:56
x
GLint GLenum GLint x
Definition: qgl_win.c:116
entity_s::skinnum
int skinnum
Definition: ref.h:70
i
int i
Definition: q_shared.c:305
refdef_t::y
int y
Definition: ref.h:122
model_s
Definition: r_model.h:171
dlight_t::origin
vec3_t origin
Definition: ref.h:91
refdef_t::rdflags
int rdflags
Definition: ref.h:128
width
GLint GLsizei width
Definition: qgl_win.c:115
entity_s::flags
int flags
Definition: ref.h:76
cvar_s
Definition: q_shared.h:317
intensity
cvar_t * intensity
Definition: gl_image.c:30
entity_s::lightstyle
int lightstyle
Definition: ref.h:72
Cmd_Argc
int Cmd_Argc(void)
Definition: cmd.c:507
Cmd_RemoveCommand
void Cmd_RemoveCommand(char *cmd_name)
Definition: cmd.c:724
entity_s::alpha
float alpha
Definition: ref.h:73
r
GLdouble GLdouble r
Definition: qgl_win.c:336
refimport_t
Definition: ref.h:218
refdef_t::num_dlights
int num_dlights
Definition: ref.h:137
particle_t::alpha
float alpha
Definition: ref.h:100
Cmd_AddCommand
void Cmd_AddCommand(char *cmd_name, xcommand_t function)
Definition: cmd.c:691
entity_s::oldframe
int oldframe
Definition: ref.h:64
dlight_t::color
vec3_t color
Definition: ref.h:92
FS_LoadFile
int FS_LoadFile(char *path, void **buffer)
Definition: files.c:394
refexport_t
Definition: ref.h:151
Cvar_SetValue
void Cvar_SetValue(char *var_name, float value)
Definition: cvar.c:317
entity_s::backlerp
float backlerp
Definition: ref.h:69
entity_t
struct entity_s entity_t
refdef_t::time
float time
Definition: ref.h:127
particle_t
Definition: ref.h:96
alpha
GLfloat GLfloat GLfloat alpha
Definition: qgl_win.c:74
refdef_t::num_particles
int num_particles
Definition: ref.h:140
particle_t::origin
vec3_t origin
Definition: ref.h:98
name
cvar_t * name
Definition: cl_main.c:94
lightstyle_t
Definition: ref.h:114
y
GLint y
Definition: qgl_win.c:115
entity_s::frame
int frame
Definition: ref.h:58
refdef_t::lightstyles
lightstyle_t * lightstyles
Definition: ref.h:132
refdef_t::particles
particle_t * particles
Definition: ref.h:141
refdef_t::num_entities
int num_entities
Definition: ref.h:134
AppActivate
void AppActivate(BOOL fActive, BOOL minimize)
Definition: vid_dll.c:242
dlight_t
Definition: ref.h:84
entity_s
Definition: ref.h:49
blue
GLfloat GLfloat blue
Definition: qgl_win.c:74
refdef_t::fov_y
float fov_y
Definition: ref.h:123
particle_t::color
int color
Definition: ref.h:99
refexport_t::api_version
int api_version
Definition: ref.h:154
FS_FreeFile
void FS_FreeFile(void *buffer)
Definition: files.c:433
refdef_t::dlights
dlight_t * dlights
Definition: ref.h:138
lightstyle_t::white
float white
Definition: ref.h:117
w
GLdouble GLdouble GLdouble w
Definition: qgl_win.c:291
image_s
Definition: r_local.h:65
refdef_t::entities
entity_t * entities
Definition: ref.h:135
mode
GLenum mode
Definition: qgl_win.c:113
GetRefAPI_t
refexport_t(* GetRefAPI_t)(refimport_t)
Definition: ref.h:272
entity_s::oldorigin
float oldorigin[3]
Definition: ref.h:63
dlight_t::intensity
float intensity
Definition: ref.h:93
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:127
entity_s::angles
float angles[3]
Definition: ref.h:52
void
void(APIENTRY *qglAccum)(GLenum op