File: client\ref.h
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 {
84 vec3_t origin;
85 vec3_t color;
86 float intensity;
87 } dlight_t;
88
89 typedef struct
90 {
91 vec3_t origin;
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
116 int num_entities;
117 entity_t *entities;
118
119 int num_dlights;
120 dlight_t *dlights;
121
122 int num_particles;
123 particle_t *particles;
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
136 int api_version;
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
184 void (*AppActivate)( qboolean activate );
185
186 } refexport_t;
187
188 //
189 // these are the functions imported by the refresh module
190 //
191 typedef struct
192 {
193 void (*Sys_Error) (int err_level, char *str, ...);
194
195 void (*Cmd_AddCommand) (char *name, void(*cmd)(void));
196 void (*Cmd_RemoveCommand) (char *name);
197 int (*Cmd_Argc) (void);
198 char *(*Cmd_Argv) (int i);
199 void (*Cmd_ExecuteText) (int exec_when, char *text);
200
201 void (*Con_Printf) (int print_level, char *str, ...);
202
203 // files will be memory mapped read only
204 // the returned buffer may be part of a larger pak file,
205 // or a discrete file from anywhere in the quake search path
206 // a -1 return means the file does not exist
207 // NULL can be passed for buf to just determine existance
208 int (*FS_LoadFile) (char *name, void **buf);
209 void (*FS_FreeFile) (void *buf);
210
211 // gamedir will be the current directory that generated
212 // files should be stored to, ie: "f:\quake\id1"
213 char *(*FS_Gamedir) (void);
214
215 cvar_t *(*Cvar_Get) (char *name, char *value, int flags);
216 cvar_t *(*Cvar_Set)( char *name, char *value );
217 void (*Cvar_SetValue)( char *name, float value );
218
219 qboolean (*Vid_GetModeInfo)( int *width, int *height, int mode );
220 void (*Vid_MenuInit)( void );
221 void (*Vid_NewWindow)( int width, int height );
222 } refimport_t;
223
224
225 // this is the only function actually exported at the linker level
226 typedef refexport_t (*GetRefAPI_t) (refimport_t);
227
228 #endif // __REF_H
229