2 Copyright (C) 1996-1997 Id Software, Inc.
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.
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.
13 See the GNU General Public License for more details.
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.
25 #include "matrixlib.h"
27 // LordHavoc: 256 dynamic lights
28 #define MAX_DLIGHTS 256
30 // this is the maximum number of input packets that can be lost without a
32 #define CL_MAX_USERCMDS 16
34 // flags for rtlight rendering
35 #define LIGHTFLAG_NORMALMODE 1
36 #define LIGHTFLAG_REALTIMEMODE 2
38 typedef struct effect_s
47 // these are for interpolation
57 // draw this as lightning polygons, or a model?
59 struct model_s *model;
65 typedef struct rtlight_s
67 // shadow volumes are done entirely in model space, so there are no matrices for dealing with them... they just use the origin
69 // note that the world to light matrices are inversely scaled (divided) by lightradius
72 // matrix for transforming world coordinates to light filter coordinates
73 matrix4x4_t matrix_worldtolight;
74 // typically 1 1 1, can be lower (dim) or higher (overbright)
76 // size of the light (remove?)
80 // light style to monitor for brightness
82 // whether light should render shadows
84 // intensity of corona to render
86 // radius scale of corona to render (1.0 means same as light radius)
87 vec_t coronasizescale;
88 // ambient intensity to render
90 // diffuse intensity to render
92 // specular intensity to render
97 // generated properties
98 // used only for shadow volumes
105 // squared cullradius
108 // rendering properties, updated each time a light is rendered
109 // this is rtlight->color * d_lightstylevalue
111 // this is R_Shadow_Cubemap(rtlight->cubemapname)
112 rtexture_t *currentcubemap;
115 // true if this light should be compiled as a static light
117 // true if this is a compiled world light, cleared if the light changes
119 // premade shadow volumes to render for world entity
120 shadowmesh_t *static_meshchain_shadow;
121 // used for visibility testing (more exact than bbox)
123 int static_numleafpvsbytes;
124 int *static_leaflist;
125 unsigned char *static_leafpvs;
126 // surfaces seen by light
127 int static_numsurfaces;
128 int *static_surfacelist;
129 // flag bits indicating which triangles of the world model should cast
130 // shadows, and which ones should be lit
132 // this avoids redundantly scanning the triangles in each surface twice
133 // for whether they should cast shadows, once in culling and once in the
134 // actual shadowmarklist production.
135 int static_numshadowtrispvsbytes;
136 unsigned char *static_shadowtrispvs;
137 // this allows the lighting batch code to skip backfaces andother culled
138 // triangles not relevant for lighting
139 // (important on big surfaces such as terrain)
140 int static_numlighttrispvsbytes;
141 unsigned char *static_lighttrispvs;
145 typedef struct dlight_s
147 // destroy light after this time
150 // the entity that owns this light (can be NULL)
152 struct entity_render_s *ent;
154 // (worldlight: saved to .rtlights file)
156 // worldlight orientation
158 // (worldlight: saved to .rtlights file)
160 // dlight orientation/scaling/location
164 // (worldlight: saved to .rtlights file)
166 // cubemap name to use on this light
167 // (worldlight: saved to .rtlights file)
168 char cubemapname[64];
169 // make light flash while selected
172 // brightness (not really radius anymore)
173 // (worldlight: saved to .rtlights file)
175 // drop intensity this much each second
178 // intensity value which is dropped over time
181 // initial values for intensity to modify
185 // light style which controls intensity of this light
186 // (worldlight: saved to .rtlights file)
189 // (worldlight: saved to .rtlights file)
192 // (worldlight: saved to .rtlights file)
194 // radius scale of corona to render (1.0 means same as light radius)
195 // (worldlight: saved to .rtlights file)
196 vec_t coronasizescale;
197 // ambient intensity to render
198 // (worldlight: saved to .rtlights file)
200 // diffuse intensity to render
201 // (worldlight: saved to .rtlights file)
203 // specular intensity to render
204 // (worldlight: saved to .rtlights file)
207 // (worldlight: saved to .rtlights file)
209 // linked list of world lights
211 struct dlight_s *next;
212 // embedded rtlight struct for renderer
218 typedef struct frameblend_s
225 // LordHavoc: this struct is intended for the renderer but some fields are
226 // used by the client.
227 typedef struct entity_render_s
233 // transform matrix for model to world
235 // transform matrix for world to model
236 matrix4x4_t inversematrix;
237 // opacity (alpha) of the model
239 // size the model is shown
244 // current uninterpolated animation frame (for things which do not use interpolation)
246 // entity shirt and pants colors (-1 if not colormapped)
248 // literal colors for renderer
249 vec3_t colormap_pantscolor;
250 vec3_t colormap_shirtcolor;
251 // light, particles, etc
258 // colormod tinting of models
261 // interpolated animation
263 // frame that the model is interpolating from
265 // frame that the model is interpolating to
267 // interpolation factor, usually computed from frame2time
269 // time frame1 began playing (for framegroup animations)
271 // time frame2 began playing (for framegroup animations)
274 // calculated by the renderer (but not persistent)
276 // calculated during R_AddModelEntities
278 // 4 frame numbers (-1 if not used) and their blending scalers (0-1), if interpolation is not desired, use frame instead
279 frameblend_t frameblend[4];
281 // current lighting from map
282 vec3_t modellight_ambient;
283 vec3_t modellight_diffuse; // q3bsp
284 vec3_t modellight_lightdir; // q3bsp
286 // last time visible during trace culling
287 double last_trace_visibility;
291 typedef struct entity_persistent_s
298 // muzzleflash fading
301 // interpolated movement
303 // start time of move
305 // time difference from start to end of move
307 // the move itself, start and end
315 typedef struct entity_s
317 // baseline state (default values)
318 entity_state_t state_baseline;
319 // previous state (interpolating from this)
320 entity_state_t state_previous;
321 // current state (interpolating to this)
322 entity_state_t state_current;
324 // used for regenerating parts of render
325 entity_persistent_t persistent;
327 // the only data the renderer should know about
328 entity_render_t render;
332 typedef struct usercmd_s
336 // intended velocities
341 vec3_t cursor_screen;
344 vec3_t cursor_impact;
345 vec3_t cursor_normal;
346 vec_t cursor_fraction;
347 int cursor_entitynumber;
351 int msec; // for qw moves
355 qboolean applied; // if false we're still accumulating a move
358 typedef struct lightstyle_s
361 char map[MAX_STYLESTRING];
364 typedef struct scoreboard_s
366 char name[MAX_SCOREBOARDNAME];
368 int colors; // two 4 bit fields
371 char qw_userinfo[MAX_USERINFO_STRING];
377 char qw_skin[MAX_QPATH];
380 typedef struct cshift_s
383 float percent; // 0-256
386 #define CSHIFT_CONTENTS 0
387 #define CSHIFT_DAMAGE 1
388 #define CSHIFT_BONUS 2
389 #define CSHIFT_POWERUP 3
390 #define CSHIFT_VCSHIFT 4
391 #define NUM_CSHIFTS 5
393 #define NAME_LENGTH 64
397 // client_state_t should hold all pieces of the client state
400 #define SIGNONS 4 // signon messages to receive before connected
403 #define MAX_DEMONAME 16
405 typedef enum cactive_e
407 ca_dedicated, // a dedicated server with no ability to start a client
408 ca_disconnected, // full screen console with no connection
409 ca_connected // valid netcon, talking to a server
413 typedef enum qw_downloadtype_e
423 typedef enum capturevideoformat_e
425 CAPTUREVIDEOFORMAT_AVI_I420
427 capturevideoformat_t;
429 typedef struct capturevideostate_s
433 // for AVI saving some values have to be written after capture ends
434 fs_offset_t videofile_totalframes_offset1;
435 fs_offset_t videofile_totalframes_offset2;
436 fs_offset_t videofile_totalsampleframes_offset;
441 capturevideoformat_t format;
444 int soundsampleframe; // for AVI saving
445 unsigned char *buffer;
446 sizebuf_t riffbuffer;
447 unsigned char riffbufferdata[128];
448 // note: riffindex buffer has an allocated ->data member, not static like most!
449 sizebuf_t riffindexbuffer;
451 fs_offset_t riffstackstartoffset[4];
452 short rgbtoyuvscaletable[3][3][256];
453 unsigned char yuvnormalizetable[3][256];
458 #define CL_MAX_DOWNLOADACKS 4
460 typedef struct cl_downloadack_s
467 // the client_static_t structure is persistent through an arbitrary number
468 // of server connections
470 typedef struct client_static_s
474 // all client memory allocations go in these pools
475 mempool_t *levelmempool;
476 mempool_t *permanentmempool;
479 // -1 = don't play demos
481 // list of demos in loop
482 char demos[MAX_DEMOS][MAX_DEMONAME];
483 // the actively playing demo (set by CL_PlayDemo_f)
486 // demo recording info must be here, because record is started before
487 // entering a map (and clearing client_state_t)
488 qboolean demorecording;
489 qboolean demoplayback;
491 // -1 = use normal cd track
494 // to meter out one message a frame
496 // host_framecount at start
498 // realtime at second frame of timedemo (LordHavoc: changed to double)
500 double td_onesecondnexttime;
501 double td_onesecondframes;
502 double td_onesecondminframes;
503 double td_onesecondmaxframes;
504 double td_onesecondavgframes;
505 int td_onesecondavgcount;
506 // LordHavoc: pausedemo
509 qboolean connect_trying;
510 int connect_remainingtries;
511 double connect_nextsendtime;
512 lhnetsocket_t *connect_mysocket;
513 lhnetaddress_t connect_address;
514 // protocol version of the server we're connected to
515 // (kept outside client_state_t because it's used between levels)
516 protocolversion_t protocol;
518 // connection information
521 // network connection
524 // download information
525 // (note: qw_download variables are also used)
526 cl_downloadack_t dp_downloadack[CL_MAX_DOWNLOADACKS];
528 // input sequence numbers are not reset on level change, only connect
530 int servermovesequence;
532 // quakeworld stuff below
534 // value of "qport" cvar at time of connection
536 // copied from cls.netcon->qw. variables every time they change, or set by demos (which have no cls.netcon)
537 int qw_incoming_sequence;
538 int qw_outgoing_sequence;
540 // current file download buffer (only saved when file is completed)
541 char qw_downloadname[MAX_QPATH];
542 unsigned char *qw_downloadmemory;
543 int qw_downloadmemorycursize;
544 int qw_downloadmemorymaxsize;
545 int qw_downloadnumber;
546 int qw_downloadpercent;
547 qw_downloadtype_t qw_downloadtype;
548 // transfer rate display
549 double qw_downloadspeedtime;
550 int qw_downloadspeedcount;
551 int qw_downloadspeedrate;
553 // current file upload buffer (for uploading screenshots to server)
554 unsigned char *qw_uploaddata;
559 // this normally contains the following keys in quakeworld:
560 // password spectator name team skin topcolor bottomcolor rate noaim msg *ver *ip
561 char userinfo[MAX_USERINFO_STRING];
563 // video capture stuff
564 capturevideostate_t capturevideo;
568 extern client_static_t cls;
570 typedef struct client_movementqueue_s
580 client_movementqueue_t;
586 qboolean drawenginesbar;
587 qboolean drawcrosshair;
592 PARTICLE_BILLBOARD = 0,
594 PARTICLE_ORIENTED_DOUBLESIDED = 2,
607 typedef struct particletype_s
610 porientation_t orientation;
617 pt_alphastatic, pt_static, pt_spark, pt_beam, pt_rain, pt_raindecal, pt_snow, pt_bubble, pt_blood, pt_smoke, pt_decal, pt_entityparticle, pt_total
621 typedef struct particle_s
623 particletype_t *type;
626 vec3_t vel; // velocity of particle, or orientation of decal, or end point of beam
628 float sizeincrease; // rate of size change per second
629 float alpha; // 0-255
630 float alphafade; // how much alpha reduces per second
631 float time2; // used for snow fluttering and decal fade
632 float bounce; // how much bounce-back from a surface the particle hits (0 = no physics, 1 = stop and slide, 2 = keep bouncing forever, 1.5 is typical)
633 float gravity; // how much gravity affects this particle (1.0 = normal gravity, 0.0 = none)
634 float airfriction; // how much air friction affects this object (objects with a low mass/size ratio tend to get more air friction)
635 float liquidfriction; // how much liquid friction affects this object (objects with a low mass/size ratio tend to get more liquid friction)
636 unsigned char color[4];
637 unsigned int owner; // decal stuck to this entity
638 model_t *ownermodel; // model the decal is stuck to (used to make sure the entity is still alive)
639 vec3_t relativeorigin; // decal at this location in entity's coordinate space
640 vec3_t relativedirection; // decal oriented this way relative to entity's coordinate space
644 typedef enum cl_parsingtextmode_e
646 CL_PARSETEXTMODE_NONE,
647 CL_PARSETEXTMODE_PING,
648 CL_PARSETEXTMODE_STATUS,
649 CL_PARSETEXTMODE_STATUS_PLAYERID,
650 CL_PARSETEXTMODE_STATUS_PLAYERIP
652 cl_parsingtextmode_t;
655 // the client_state_t structure is wiped completely at every
658 typedef struct client_state_s
660 // true if playing in a local game and no one else is connected
663 // send a clc_nop periodically until connected
666 // current input being accumulated by mouse/joystick/etc input
668 // latest moves sent to the server that have not been confirmed yet
669 usercmd_t movecmd[CL_MAX_USERCMDS];
671 // information for local display
673 int stats[MAX_CL_STATS];
674 // last known inventory bit flags, for blinking
676 // cl.time of acquiring item, for blinking
677 float item_gettime[32];
678 // last known STAT_ACTIVEWEAPON
680 // cl.time of changing STAT_ACTIVEWEAPON
682 // use pain anim frame if cl.time < this
684 // for stair smoothing
686 double stairsmoothtime;
688 // color shifts for damage, powerups
689 cshift_t cshifts[NUM_CSHIFTS];
691 cshift_t prev_cshifts[NUM_CSHIFTS];
693 // the client maintains its own idea of view angles, which are
694 // sent to the server each frame. The server sets punchangle when
695 // the view is temporarily offset, and an angle reset commands at the start
696 // of each level and after teleporting.
698 // mviewangles is read from demo
699 // viewangles is either client controlled or lerped from mviewangles
700 vec3_t mviewangles[2], viewangles;
701 // update by server, used by qc to do weapon recoil
702 vec3_t mpunchangle[2], punchangle;
703 // update by server, can be used by mods to kick view around
704 vec3_t mpunchvector[2], punchvector;
705 // update by server, used for lean+bob (0 is newest)
706 vec3_t mvelocity[2], velocity;
707 // update by server, can be used by mods for zooming
708 vec_t mviewzoom[2], viewzoom;
709 // if true interpolation the mviewangles and other interpolation of the
710 // player is disabled until the next network packet
711 // this is used primarily by teleporters, and when spectating players
712 // special checking of the old fixangle[1] is used to differentiate
713 // between teleporting and spectating
714 qboolean fixangle[2];
716 // client movement simulation
717 // these fields are only updated by CL_ClientMovement (called by CL_SendMove after parsing each network packet)
718 // set by CL_ClientMovement_Replay functions
719 qboolean movement_predicted;
720 // this is set true by svc_time parsing and causes a new movement to be
721 // queued for prediction purposes
722 qboolean movement_needupdate;
723 // timestamps of latest two predicted moves for interpolation
724 double movement_time[4];
725 // simulated data (this is valid even if cl.movement is false)
726 vec3_t movement_origin;
727 vec3_t movement_oldorigin;
728 vec3_t movement_velocity;
729 // queue of proposed moves
730 int movement_numqueue;
731 client_movementqueue_t movement_queue[256];
732 // whether the replay should allow a jump at the first sequence
733 qboolean movement_replay_canjump;
735 // pitch drifting vars
742 //[515]: added for csqc purposes
743 float sensitivityscale;
744 csqc_vidvars_t csqc_vidvars; //[515]: these parms must be set to true by default
745 qboolean csqc_wantsmousemove;
746 struct model_s *csqc_model_precache[MAX_MODELS];
748 // local amount for smoothing stepups
757 qboolean oldonground;
758 double lastongroundtime;
759 double hitgroundtime;
761 // don't change view angle, full screen, etc
763 // latched at intermission start
764 double completed_time;
766 // the timestamp of the last two messages
769 // clients view of time, time should be between mtime[0] and mtime[1] to
770 // generate a lerp point for other data, oldtime is the previous frame's
771 // value of time, frametime is the difference between time and oldtime
772 // note: cl.time may be beyond cl.mtime[0] if packet loss is occuring, it
773 // is only forcefully limited when a packet is received
774 double time, oldtime;
775 // how long it has been since the previous client frame in real time
776 // (not game time, for that use cl.time - cl.oldtime)
777 double realframetime;
779 // copy of realtime from last recieved message, for net trouble icon
780 float last_received_message;
782 // information that is static for the entire time connected to a server
783 struct model_s *model_precache[MAX_MODELS];
784 struct sfx_s *sound_precache[MAX_SOUNDS];
786 // FIXME: this is a lot of memory to be keeping around, this really should be dynamically allocated and freed somehow
787 char model_name[MAX_MODELS][MAX_QPATH];
788 char sound_name[MAX_SOUNDS][MAX_QPATH];
790 // for display on solo scoreboard
792 // cl_entitites[cl.viewentity] = player
794 // the real player entity (normally same as viewentity,
795 // different than viewentity if mod uses chasecam or other tricks)
797 // max players that can be in this game
799 // type of game (deathmatch, coop, singleplayer)
802 // models and sounds used by engine code (particularly cl_parse.c)
804 model_t *model_bolt2;
805 model_t *model_bolt3;
808 sfx_t *sfx_knighthit;
815 // refresh related state
817 // cl_entitites[0].model
818 struct model_s *worldmodel;
824 int cdtrack, looptrack;
829 scoreboard_t *scores;
831 // keep track of svc_print parsing state (analyzes ping reports and status reports)
832 cl_parsingtextmode_t parsingtextmode;
833 int parsingtextplayerindex;
834 // set by scoreboard code when sending ping command, this causes the next ping results to be hidden
835 // (which could eat the wrong ping report if the player issues one
836 // manually, but they would still see a ping report, just a later one
837 // caused by the scoreboard code rather than the one they intentionally
839 int parsingtextexpectingpingforscores;
841 // entity database stuff
842 // latest received entity frame numbers
843 #define LATESTFRAMENUMS 3
844 int latestframenums[LATESTFRAMENUMS];
845 entityframe_database_t *entitydatabase;
846 entityframe4_database_t *entitydatabase4;
847 entityframeqw_database_t *entitydatabaseqw;
849 // keep track of quake entities because they need to be killed if they get stale
851 unsigned char isquakeentity[MAX_EDICTS];
853 // bounding boxes for clientside movement
854 vec3_t playerstandmins;
855 vec3_t playerstandmaxs;
856 vec3_t playercrouchmins;
857 vec3_t playercrouchmaxs;
860 int max_static_entities;
861 int max_temp_entities;
866 int max_brushmodel_entities;
870 unsigned char *entities_active;
871 entity_t *static_entities;
872 entity_t *temp_entities;
873 cl_effect_t *effects;
876 lightstyle_t *lightstyle;
877 int *brushmodel_entities;
878 particle_t *particles;
881 int num_static_entities;
882 int num_temp_entities;
883 int num_brushmodel_entities;
891 // cl_serverextension_download feature
892 int loadmodel_current;
893 int downloadmodel_current;
895 int loadsound_current;
896 int downloadsound_current;
898 qboolean downloadcsqc;
900 qboolean loadfinished;
904 // local copy of the server infostring
905 char qw_serverinfo[MAX_SERVERINFO_STRING];
907 // time of last qw "pings" command sent to server while showing scores
908 double last_ping_request;
910 // used during connect
913 // updated from serverinfo
916 // unused: indicates whether the player is spectating
917 // use cl.scores[cl.playerentity].qw_spectator instead
918 //qboolean qw_spectator;
920 // movement parameters for client prediction
921 float qw_movevars_gravity;
922 float qw_movevars_stopspeed;
923 float qw_movevars_maxspeed; // can change during play
924 float qw_movevars_spectatormaxspeed;
925 float qw_movevars_accelerate;
926 float qw_movevars_airaccelerate;
927 float qw_movevars_wateraccelerate;
928 float qw_movevars_friction;
929 float qw_movevars_waterfriction;
930 float qw_movevars_entgravity; // can change during play
932 // models used by qw protocol
933 int qw_modelindex_spike;
934 int qw_modelindex_player;
935 int qw_modelindex_flag;
936 int qw_modelindex_s_explod;
938 vec3_t qw_intermission_origin;
939 vec3_t qw_intermission_angles;
941 // 255 is the most nails the QW protocol could send
943 vec_t qw_nails[255][6];
947 int qw_validsequence;
949 int qw_deltasequence[QW_UPDATE_BACKUP];
953 // collision culling data
961 extern cvar_t cl_name;
962 extern cvar_t cl_color;
963 extern cvar_t cl_rate;
964 extern cvar_t cl_pmodel;
965 extern cvar_t cl_playermodel;
966 extern cvar_t cl_playerskin;
968 extern cvar_t rcon_password;
969 extern cvar_t rcon_address;
971 extern cvar_t cl_upspeed;
972 extern cvar_t cl_forwardspeed;
973 extern cvar_t cl_backspeed;
974 extern cvar_t cl_sidespeed;
976 extern cvar_t cl_movespeedkey;
978 extern cvar_t cl_yawspeed;
979 extern cvar_t cl_pitchspeed;
981 extern cvar_t cl_anglespeedkey;
983 extern cvar_t cl_autofire;
985 extern cvar_t cl_shownet;
986 extern cvar_t cl_nolerp;
987 extern cvar_t cl_nettimesyncmode;
989 extern cvar_t cl_pitchdriftspeed;
990 extern cvar_t lookspring;
991 extern cvar_t lookstrafe;
992 extern cvar_t sensitivity;
994 extern cvar_t freelook;
996 extern cvar_t m_pitch;
998 extern cvar_t m_forward;
999 extern cvar_t m_side;
1001 extern cvar_t cl_autodemo;
1002 extern cvar_t cl_autodemo_nameformat;
1004 extern cvar_t r_draweffects;
1006 extern cvar_t cl_explosions_alpha_start;
1007 extern cvar_t cl_explosions_alpha_end;
1008 extern cvar_t cl_explosions_size_start;
1009 extern cvar_t cl_explosions_size_end;
1010 extern cvar_t cl_explosions_lifetime;
1011 extern cvar_t cl_stainmaps;
1012 extern cvar_t cl_stainmaps_clearonload;
1014 extern cvar_t cl_prydoncursor;
1016 extern client_state_t cl;
1018 extern void CL_AllocLightFlash (entity_render_t *ent, matrix4x4_t *matrix, float radius, float red, float green, float blue, float decay, float lifetime, int cubemapnum, int style, int shadowenable, vec_t corona, vec_t coronasizescale, vec_t ambientscale, vec_t diffusescale, vec_t specularscale, int flags);
1020 //=============================================================================
1026 void CL_Shutdown (void);
1027 void CL_Init (void);
1029 void CL_EstablishConnection(const char *host);
1031 void CL_Disconnect (void);
1032 void CL_Disconnect_f (void);
1034 void CL_UpdateRenderEntity(entity_render_t *ent);
1035 void CL_UpdateEntities(void);
1040 typedef struct kbutton_s
1042 int down[2]; // key nums holding it down
1043 int state; // low bit is down state
1047 extern kbutton_t in_mlook, in_klook;
1048 extern kbutton_t in_strafe;
1049 extern kbutton_t in_speed;
1051 void CL_InitInput (void);
1052 void CL_SendMove (void);
1054 void CL_ValidateState(entity_state_t *s);
1055 void CL_MoveLerpEntityStates(entity_t *ent);
1056 void CL_LerpUpdate(entity_t *e);
1057 void CL_ParseTEnt (void);
1058 void CL_NewBeam (int ent, vec3_t start, vec3_t end, model_t *m, int lightning);
1059 void CL_RelinkBeams (void);
1060 void CL_Beam_CalculatePositions (const beam_t *b, vec3_t start, vec3_t end);
1062 void CL_ClearTempEntities (void);
1063 entity_t *CL_NewTempEntity (void);
1065 void CL_Effect(vec3_t org, int modelindex, int startframe, int framecount, float framerate);
1067 void CL_ClearState (void);
1068 void CL_ExpandEntities(int num);
1069 void CL_SetInfo(const char *key, const char *value, qboolean send, qboolean allowstarkey, qboolean allowmodel, qboolean quiet);
1072 int CL_ReadFromServer (void);
1073 void CL_WriteToServer (void);
1074 void CL_Input (void);
1075 extern qboolean cl_ignoremousemove;
1078 float CL_KeyState (kbutton_t *key);
1079 const char *Key_KeynumToString (int keynum);
1080 int Key_StringToKeynum (const char *str);
1085 void CL_StopPlayback(void);
1086 void CL_ReadDemoMessage(void);
1087 void CL_WriteDemoMessage(void);
1089 void CL_NextDemo(void);
1090 void CL_Stop_f(void);
1091 void CL_Record_f(void);
1092 void CL_PlayDemo_f(void);
1093 void CL_TimeDemo_f(void);
1098 void CL_Parse_Init(void);
1099 void CL_Parse_Shutdown(void);
1100 void CL_ParseServerMessage(void);
1101 void CL_Parse_DumpPacket(void);
1102 void CL_Parse_ErrorCleanUp(void);
1103 void QW_CL_StartUpload(unsigned char *data, int size);
1104 extern cvar_t qport;
1109 void V_StartPitchDrift (void);
1110 void V_StopPitchDrift (void);
1113 float V_CalcRoll (vec3_t angles, vec3_t velocity);
1114 void V_UpdateBlends (void);
1115 void V_ParseDamage (void);
1121 extern cvar_t cl_particles;
1122 extern cvar_t cl_particles_quality;
1123 extern cvar_t cl_particles_size;
1124 extern cvar_t cl_particles_quake;
1125 extern cvar_t cl_particles_blood;
1126 extern cvar_t cl_particles_blood_alpha;
1127 extern cvar_t cl_particles_blood_bloodhack;
1128 extern cvar_t cl_particles_bulletimpacts;
1129 extern cvar_t cl_particles_explosions_smoke;
1130 extern cvar_t cl_particles_explosions_sparks;
1131 extern cvar_t cl_particles_explosions_shell;
1132 extern cvar_t cl_particles_smoke;
1133 extern cvar_t cl_particles_smoke_alpha;
1134 extern cvar_t cl_particles_smoke_alphafade;
1135 extern cvar_t cl_particles_sparks;
1136 extern cvar_t cl_particles_bubbles;
1137 extern cvar_t cl_decals;
1138 extern cvar_t cl_decals_time;
1139 extern cvar_t cl_decals_fadetime;
1141 void CL_Particles_Clear(void);
1142 void CL_Particles_Init(void);
1143 void CL_Particles_Shutdown(void);
1145 typedef enum effectnameindex_s
1149 EFFECT_TE_GUNSHOTQUAD,
1151 EFFECT_TE_SPIKEQUAD,
1152 EFFECT_TE_SUPERSPIKE,
1153 EFFECT_TE_SUPERSPIKEQUAD,
1155 EFFECT_TE_KNIGHTSPIKE,
1156 EFFECT_TE_EXPLOSION,
1157 EFFECT_TE_EXPLOSIONQUAD,
1158 EFFECT_TE_TAREXPLOSION,
1160 EFFECT_TE_LAVASPLASH,
1161 EFFECT_TE_SMALLFLASH,
1166 EFFECT_TE_PLASMABURN,
1168 EFFECT_TE_TEI_SMOKE,
1169 EFFECT_TE_TEI_BIGEXPLOSION,
1170 EFFECT_TE_TEI_PLASMAHIT,
1176 EFFECT_TR_SLIGHTBLOOD,
1177 EFFECT_TR_KNIGHTSPIKE,
1178 EFFECT_TR_VORESPIKE,
1179 EFFECT_TR_NEHAHRASMOKE,
1180 EFFECT_TR_NEXUIZPLASMA,
1181 EFFECT_TR_GLOWTRAIL,
1182 EFFECT_SVC_PARTICLE,
1187 int CL_ParticleEffectIndexForName(const char *name);
1188 const char *CL_ParticleEffectNameForIndex(int i);
1189 void CL_ParticleEffect(int effectindex, float pcount, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor);
1190 void CL_ParticleTrail(int effectindex, float pcount, const vec3_t originmins, const vec3_t originmaxs, const vec3_t velocitymins, const vec3_t velocitymaxs, entity_t *ent, int palettecolor, qboolean spawndlight, qboolean spawnparticles);
1191 void CL_ParseParticleEffect (void);
1192 void CL_ParticleCube (const vec3_t mins, const vec3_t maxs, const vec3_t dir, int count, int colorbase, vec_t gravity, vec_t randomvel);
1193 void CL_ParticleRain (const vec3_t mins, const vec3_t maxs, const vec3_t dir, int count, int colorbase, int type);
1194 void CL_EntityParticles (const entity_t *ent);
1195 void CL_ParticleExplosion (const vec3_t org);
1196 void CL_ParticleExplosion2 (const vec3_t org, int colorStart, int colorLength);
1197 void CL_MoveParticles(void);
1198 void R_MoveExplosions(void);
1199 void R_NewExplosion(const vec3_t org);
1201 void Debug_PolygonBegin(const char *picname, int flags, qboolean draw2d, float linewidth);
1202 void Debug_PolygonVertex(float x, float y, float z, float s, float t, float r, float g, float b, float a);
1203 void Debug_PolygonEnd(void);
1205 #include "cl_screen.h"
1207 extern qboolean sb_showscores;
1209 #define NUMCROSSHAIRS 32
1210 extern cachepic_t *r_crosshairs[NUMCROSSHAIRS+1];
1212 #define FOGTABLEWIDTH 1024
1213 extern int fogtableindex;
1214 #define VERTEXFOGTABLE(dist) (fogtableindex = (int)((dist) * r_refdef.fogtabledistmultiplier), r_refdef.fogtable[bound(0, fogtableindex, FOGTABLEWIDTH - 1)])
1216 typedef struct r_refdef_stats_s
1219 int entities_surfaces;
1220 int entities_triangles;
1225 int meshes_elements;
1228 int lights_scissored;
1229 int lights_lighttriangles;
1230 int lights_shadowtriangles;
1231 int lights_dynamicshadowtriangles;
1233 int bloom_copypixels;
1234 int bloom_drawpixels;
1238 typedef struct r_refdef_s
1240 // these fields define the basic rendering information for the world
1241 // but not the view, which could change multiple times in one rendered
1242 // frame (for example when rendering textures for certain effects)
1244 // these are set for water warping before
1245 // frustum_x/frustum_y are calculated
1246 float frustumscale_x, frustumscale_y;
1248 // minimum visible distance (pixels closer than this disappear)
1250 // maximum visible distance (pixels further than this disappear in 16bpp modes,
1251 // in 32bpp an infinite-farclip matrix is used instead)
1254 // fullscreen color blend
1257 // whether to call S_ExtraUpdate during render to reduce sound chop
1258 qboolean extraupdate;
1260 // client gameworld time for rendering time based effects
1264 entity_render_t *worldentity;
1266 // same as worldentity->model
1267 model_t *worldmodel;
1269 // renderable entities (excluding world)
1270 entity_render_t **entities;
1274 // renderable dynamic lights
1275 rtlight_t lights[MAX_DLIGHTS];
1278 // 8.8bit fixed point intensities for light styles
1279 // controls intensity of dynamic lights and lightmap layers
1280 unsigned short lightstylevalue[256]; // 8.8 fraction of base light value
1284 vec_t fograngerecip;
1285 vec_t fogtabledistmultiplier;
1286 float fogtable[FOGTABLEWIDTH];
1291 qboolean fogenabled;
1292 qboolean oldgl_fogenable;
1294 qboolean draw2dstage;
1296 // true during envmap command capture
1299 // brightness of world lightmaps and related lighting
1300 // (often reduced when world rtlights are enabled)
1301 float lightmapintensity;
1302 // whether to draw world lights realtime, dlights realtime, and their shadows
1304 qboolean rtworldshadows;
1306 qboolean rtdlightshadows;
1307 float polygonfactor;
1308 float polygonoffset;
1309 float shadowpolygonfactor;
1310 float shadowpolygonoffset;
1312 // rendering stats for r_speeds display
1313 // (these are incremented in many places)
1314 r_refdef_stats_t stats;
1318 typedef struct r_view_s
1320 // view information (changes multiple times per frame)
1321 // if any of these variables change then r_viewcache must be regenerated
1322 // by calling R_View_Update
1323 // (which also updates viewport, scissor, colormask)
1325 // it is safe and expected to copy this into a structure on the stack and
1326 // call the renderer recursively, then restore from the stack afterward
1327 // (as long as R_View_Update is called)
1329 // eye position information
1336 mplane_t frustum[5];
1337 float frustum_x, frustum_y;
1339 // screen area to render in
1347 // which color components to allow (for anaglyph glasses)
1350 // global RGB color multiplier for rendering, this is required by HDR
1355 typedef struct r_viewcache_s
1357 // these properties are generated by R_View_Update()
1359 // which entities are currently visible for this viewpoint
1360 // (the used range is 0...r_refdef.numentities)
1361 unsigned char entityvisible[MAX_EDICTS];
1362 // flag arrays used for visibility checking on world model
1363 // (all other entities have no per-surface/per-leaf visibility checks)
1364 // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_clusters
1365 unsigned char world_pvsbits[(32768+7)>>3];
1366 // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_leafs
1367 unsigned char world_leafvisible[32768];
1368 // TODO: dynamic resize according to r_refdef.worldmodel->num_surfaces
1369 unsigned char world_surfacevisible[262144];
1370 // if true, the view is currently in a leaf without pvs data
1371 qboolean world_novis;
1375 extern r_refdef_t r_refdef;
1376 extern r_view_t r_view;
1377 extern r_viewcache_t r_viewcache;