altEngine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
engine.h
Go to the documentation of this file.
1 #include "include.h"
2 
3 #ifndef ENGINE_H
4 #define ENGINE_H
5 
6 class Engine
7 {
8  friend class Quake3;
9  friend class Commando;
10 
11 public:
12  Engine();
13  void init(void *param1, void *param2, char *cmdline);
14  void load(char *level);
15  void unload();
16  void destroy();
17  void quit();
18 
19  void render(double last_frametime);
20  void render_scene(bool lights);
21  void render_scene_using_shadowmap(bool lights);
22  void render_entities(const matrix4 &trans, matrix4 &proj, bool lights, bool blend, bool vis = true);
23  void render_shadow_volumes();
24 
25 
26  void render_shadowmaps(bool everything);
27  void render_portalcamera();
28  void render_texture(int texObj, bool depth_view);
29  void post_process(int num_passes, int type);
30  void render_bloom(bool debug);
31  void render_skyray(bool debug);
32  void render_wave(bool debug);
33  void resize(int width, int height);
34  void fullscreen();
35 
36  void step(int tick_num);
37  void dynamics();
38  void handle_springs();
39  void spatial_testing();
40  void activate_light(float distance, Light *light);
41  void update_audio();
42  void set_reference_distance(float value);
43  void set_max_distance(float value);
44  void set_rolloff_factor(float value);
45 
46  bool mousepos(int x, int y, int deltax, int deltay);
47  void keypress(char *key, bool pressed);
48  void keystroke(char key, char *keystr);
49 
50  void load_entities();
51  int get_entity();
52  int get_player();
53  int find_type(int ent_type, int skip);
54  void clean_entity(int index);
55  void load_models();
56  void create_sources();
57 
58  void console(char *cmd);
59  void handle_game(char key);
60 
61  bool collision_detect(RigidBody &body);
62  bool map_collision(RigidBody &body);
63 
64  bool body_collision(RigidBody &body);
65 
66  void get_shaderlist_pk3(char **shaderlist, int &num_shader);
67 
68  int bind(int port);
69  void connect(char *server);
70  void chat(char *name, char *msg);
71  void kick(unsigned int i);
72  int GetKeyState(input_t &keyboard);
73  input_t GetKeyState(int keystate);
74  void bind_keys();
75  void server_recv();
76  void server_send();
77  void server_send_state(int client);
78  void set_spawn_string(char *msg, client_t *client);
79  void parse_spawn_string(char *msg);
80  void client_recv();
81  void client_send();
82  int handle_servermsg(servermsg_t &servermsg, unsigned char *data, reliablemsg_t *reliablemsg);
83  void render_weapon(const matrix4 &trans, bool lights, int i);
84  void render_trails(matrix4 &trans);
85  void render_players(matrix4 &trans, matrix4 &projection, bool lights, bool self);
86 
87 
88  int serialize_ents(unsigned char *data, unsigned short int &num_ents, unsigned int &data_size);
89  int deserialize_ents(unsigned char *data, unsigned short int num_ents, unsigned int data_size);
90  int deserialize_net_player(net_player_t *player, int index, int etype);
91  int deserialize_net_rigid(net_rigid_t *rigid, int index, int etype);
92  int deserialize_net_trigger(net_trigger_t *net, int index, int etype);
93  int deserialize_net_projectile(net_projectile_t *net, int index, int etype);
94 
95  bool select_wave(int source, char *file);
96 
97  // Hit max source limit, only moving entities really need them
98  bool play_wave_source(int source, int index);
99  // Rest will play from 32 sources round robin style
100  int play_wave(vec3 &position, int index);
101  int play_wave_loop(vec3 &position, int index);
102  int play_wave_global(int index);
103  int play_wave_global_loop(int index);
104  int get_load_wave(const char *file);
105  void screenshot(unsigned int &luminance, bool luminance_only);
106  void paste(char *data, unsigned int size);
107  void copy(char *data, unsigned int size);
108 
109  void destroy_buffers();
110  void render_to_framebuffer(double last_frametime);
111  void set_dynamic_resolution(double last_frametime);
112 
113  void hitscan(vec3 &origin, vec3 &dir, int *index_list, int &num_index, int self, float range);
114  void load_md5();
115  void find_path(int *&path, int &path_length, int start_path, int end_path);
116  void zoom(float level);
117  void reload_shaders();
118  void enum_resolutions();
119 
120  int get_source();
121  int get_loop_source();
122  int get_global_source();
124  bool terrain_collision(RigidBody &body);
125 
126 
127  unsigned int xres, yres;
128  unsigned int tick_num;
129 
130  unsigned int lum_table[125];
131  unsigned int lum_index;
132  unsigned int lum_avg;
133 
134 
135 
136 
137 //temp
138  unsigned int testObj;
139  unsigned int num_light;
141  unsigned int fullscreen_timer;
142  unsigned int ingame_menu_timer;
145 
146  unsigned int audio_source[32];
147  unsigned int global_source[32];
148  unsigned int audio_loop_source[32];
149  unsigned int global_loop_source[32];
151 
154 
155  char *pk3_list[32];
156  unsigned int num_pk3;
157  char *hash_list[32];
158  char hash_result[64][32];
159  unsigned int num_hash;
160 
161 
162  unsigned int controller;
163 
164 
165 
166  char *cmd_list[1024];
167  unsigned int num_cmd;
168  char *shader_list[256];
171 
172  char *pk3list;
173  char *cmdlist;
174  char *hashlist;
175  char *hacklist;
176  char *wad;
177 
179 
180 //console flags
184  bool show_hud;
186  bool demo;
202 
203 
204  char resbuf[MAX_RES][80];
205  int num_res;
207 
211  int num_team;
212 
213 
214 //Game logic
216 
221 
222  unsigned int num_bot;
223  unsigned int shadow_light;
224 
226  float res_scale;
227 
228  //ssao temp
230 
231  void render_ssao(bool debug);
232 
233 
235  float ssao_level;
237  float ssao_radius;
240  unsigned int point_count;
241 
245 
246  float dof_near;
247  float dof_far;
248 
249 #ifdef WIN32
250  HWAVEOUT hWaveOut;
251 #endif
252 
253  float zNear;
254  float zFar;
255  bool inf;
256  float fov; // y fov
257 
258 protected:
261  float sensitivity;
262 
268 
269 
270  unsigned int spiral_vbo;
271  unsigned int spiral_ibo;
272  unsigned int lightning_ibo;
273  unsigned int lightning_vbo;
274  unsigned int global_vao;
275 
276  unsigned int render_fbo;
277  unsigned int mask_fbo;
278  unsigned int blur1_fbo;
279  unsigned int blur2_fbo;
280  unsigned int ssao_fbo;
281 
282 
283  unsigned int render_quad;
284  unsigned int render_depth;
285  unsigned int render_ndepth;
286 
287  unsigned int mask_quad;
288  unsigned int mask_depth;
289 
290  unsigned int blur1_quad;
291  unsigned int blur1_depth;
292 
293  unsigned int blur2_quad;
294  unsigned int blur2_depth;
295 
296  unsigned int ssao_quad;
297  unsigned int ssao_depth;
298 
299  unsigned int fb_width;
300  unsigned int fb_height;
301  unsigned int multisample;
302  unsigned int no_tex;
303  unsigned int particle_tex;
304 
305  unsigned int palette1;
306  unsigned int palette2;
307 
308 
309  bool voted;
310  unsigned int vote_yes;
311  unsigned int vote_no;
312 
314  unsigned int max_dynamic;
315  unsigned int max_player;
316 
319 
320 
321  //net stuff
322  int sequence;
326  int cl_skip;
327  char sv_hostname[512];
328  char sv_motd[512];
329  char password[512];
330  unsigned int sv_maxclients;
331  unsigned short int net_port;
332 
335  FILE *demofile;
336 
337 
339 
340 
341  int server_spawn; // entity index of hosting player
342 
343  // pathfinding stuff
344  Graph graph;
347 
348 
349  //server
352 
353  //client
355  unsigned int last_server_sequence;
356  unsigned int qport;
357  bool active_clients[8];
358 
360 
361  //Shaders
362  Global global; // basic shader for menu's etc
363  Post post; // post process shader
364  mLight2 mlight2; // main shader for lighting
365 
369  unsigned int emitter_count;
370 
371 
373  void *param1;
374  void *param2;
375 };
376 
377 #endif
378