vkQuake2 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 
78 } entity_t;
79 
80 #define ENTITY_FLAGS 68
81 
82 typedef struct
83 {
86  float intensity;
87 } dlight_t;
88 
89 typedef struct
90 {
92  int color;
93  float alpha;
94 } particle_t;
95 
96 typedef struct
97 {
98  float rgb[3]; // 0.0 - 2.0
99  float white; // highest of rgb
100 } lightstyle_t;
101 
102 typedef struct
103 {
104  int x, y, width, height;// in virtual screen coordinates
105  float fov_x, fov_y;
106  float vieworg[3];
107  float viewangles[3];
108  float blend[4]; // rgba 0-1 full screen blend
109  float time; // time is uesed to auto animate
110  int rdflags; // RDF_UNDERWATER, etc
111 
112  byte *areabits; // if not NULL, only areas with set bits will be drawn
113 
114  lightstyle_t *lightstyles; // [MAX_LIGHTSTYLES]
115 
118 
121 
124 } refdef_t;
125 
126 
127 
128 #define API_VERSION 3
129 
130 //
131 // these are the functions exported by the refresh module
132 //
133 typedef struct
134 {
135  // if api_version is different, the dll cannot be used
137 
138  // called when the library is loaded
139  qboolean (*Init) ( void *hinstance, void *wndproc );
140 
141  // called before the library is unloaded
142  void (*Shutdown) (void);
143 
144  // All data that will be used in a level should be
145  // registered before rendering any frames to prevent disk hits,
146  // but they can still be registered at a later time
147  // if necessary.
148  //
149  // EndRegistration will free any remaining data that wasn't registered.
150  // Any model_s or skin_s pointers from before the BeginRegistration
151  // are no longer valid after EndRegistration.
152  //
153  // Skins and images need to be differentiated, because skins
154  // are flood filled to eliminate mip map edge errors, and pics have
155  // an implicit "pics/" prepended to the name. (a pic name that starts with a
156  // slash will not use the "pics/" prefix or the ".pcx" postfix)
157  void (*BeginRegistration) (char *map);
158  struct model_s *(*RegisterModel) (char *name);
159  struct image_s *(*RegisterSkin) (char *name);
160  struct image_s *(*RegisterPic) (char *name);
161  void (*SetSky) (char *name, float rotate, vec3_t axis);
162  void (*EndRegistration) (void);
163 
164  void (*RenderFrame) (refdef_t *fd);
165 
166  void (*DrawGetPicSize) (int *w, int *h, char *name); // will return 0 0 if not found
167  void (*DrawPic) (int x, int y, char *name);
168  void (*DrawStretchPic) (int x, int y, int w, int h, char *name);
169  void (*DrawChar) (int x, int y, int c);
170  void (*DrawTileClear) (int x, int y, int w, int h, char *name);
171  void (*DrawFill) (int x, int y, int w, int h, int c);
172  void (*DrawFadeScreen) (void);
173 
174  // Draw images for cinematic rendering (which can have a different palette). Note that calls
175  void (*DrawStretchRaw) (int x, int y, int w, int h, int cols, int rows, byte *data);
176 
177  /*
178  ** video mode and refresh state management entry points
179  */
180  void (*CinematicSetPalette)( const unsigned char *palette); // NULL = game palette
181  void (*BeginFrame)( float camera_separation );
182  void (*EndFrame) (void);
183  void (*EndWorldRenderpass) (void); // finish world rendering, apply postprocess and switch to UI render pass
184 
185  void (*AppActivate)( qboolean activate );
186 
187 } refexport_t;
188 
189 //
190 // these are the functions imported by the refresh module
191 //
192 typedef struct
193 {
194  void (*Sys_Error) (int err_level, char *str, ...);
195 
196  void (*Cmd_AddCommand) (char *name, void(*cmd)(void));
199  char *(*Cmd_Argv) (int i);
200  void (*Cmd_ExecuteText) (int exec_when, char *text);
201 
202  void (*Con_Printf) (int print_level, char *str, ...);
203 
204  // files will be memory mapped read only
205  // the returned buffer may be part of a larger pak file,
206  // or a discrete file from anywhere in the quake search path
207  // a -1 return means the file does not exist
208  // NULL can be passed for buf to just determine existance
209  int (*FS_LoadFile) (char *name, void **buf);
210  void (*FS_FreeFile) (void *buf);
211 
212  // gamedir will be the current directory that generated
213  // files should be stored to, ie: "f:\quake\id1"
214  char *(*FS_Gamedir) (void);
215 
216  cvar_t *(*Cvar_Get) (char *name, char *value, int flags);
217  cvar_t *(*Cvar_Set)( char *name, char *value );
218  void (*Cvar_SetValue)( char *name, float value );
219 
220  qboolean (*Vid_GetModeInfo)( int *width, int *height, int mode );
221  void (*Vid_MenuInit)( void );
222  void (*Vid_NewWindow)( int width, int height );
223 } refimport_t;
224 
225 
226 // this is the only function actually exported at the linker level
228 
229 #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:102
int
CONST PIXELFORMATDESCRIPTOR int
Definition: qgl_win.c:35
refdef_t::areabits
byte * areabits
Definition: ref.h:112
Sys_Error
void Sys_Error(char *error,...)
Definition: sys_win.c:68
qboolean
qboolean
Definition: q_shared.h:63
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:104
model_s
Definition: r_model.h:171
dlight_t::origin
vec3_t origin
Definition: ref.h:84
refdef_t::rdflags
int rdflags
Definition: ref.h:110
width
GLint GLsizei width
Definition: qgl_win.c:115
entity_s::flags
int flags
Definition: ref.h:76
cvar_s
Definition: q_shared.h:324
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
refimport_t
Definition: ref.h:192
refdef_t::num_dlights
int num_dlights
Definition: ref.h:119
particle_t::alpha
float alpha
Definition: ref.h:93
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:85
FS_LoadFile
int FS_LoadFile(char *path, void **buffer)
Definition: files.c:398
refexport_t
Definition: ref.h:133
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:109
particle_t
Definition: ref.h:89
refdef_t::num_particles
int num_particles
Definition: ref.h:122
particle_t::origin
vec3_t origin
Definition: ref.h:91
name
cvar_t * name
Definition: cl_main.c:79
lightstyle_t
Definition: ref.h:96
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:114
refdef_t::particles
particle_t * particles
Definition: ref.h:123
refdef_t::num_entities
int num_entities
Definition: ref.h:116
AppActivate
void AppActivate(BOOL fActive, BOOL minimize)
Definition: vid_dll.c:247
dlight_t
Definition: ref.h:82
entity_s
Definition: ref.h:49
refdef_t::fov_y
float fov_y
Definition: ref.h:105
particle_t::color
int color
Definition: ref.h:92
refexport_t::api_version
int api_version
Definition: ref.h:136
FS_FreeFile
void FS_FreeFile(void *buffer)
Definition: files.c:437
refdef_t::dlights
dlight_t * dlights
Definition: ref.h:120
lightstyle_t::white
float white
Definition: ref.h:99
w
GLdouble GLdouble GLdouble w
Definition: qgl_win.c:291
image_s
Definition: r_local.h:71
refdef_t::entities
entity_t * entities
Definition: ref.h:117
mode
GLenum mode
Definition: qgl_win.c:113
GetRefAPI_t
refexport_t(* GetRefAPI_t)(refimport_t)
Definition: ref.h:227
entity_s::oldorigin
float oldorigin[3]
Definition: ref.h:63
dlight_t::intensity
float intensity
Definition: ref.h:86
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:134
entity_s::angles
float angles[3]
Definition: ref.h:52
void
void(APIENTRY *qglAccum)(GLenum op