]> icculus.org git repositories - divverent/darkplaces.git/blob - render.h
added support for transparent model skins
[divverent/darkplaces.git] / render.h
1 /*
2 Copyright (C) 1996-1997 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
21 // refresh.h -- public interface to refresh functions
22
23 // far clip distance for scene
24 extern cvar_t r_farclip;
25
26 // fog stuff
27 extern void FOG_clear(void);
28 extern float fog_density, fog_red, fog_green, fog_blue;
29
30 // SHOWLMP stuff (Nehahra)
31 extern void SHOWLMP_decodehide(void);
32 extern void SHOWLMP_decodeshow(void);
33 extern void SHOWLMP_drawall(void);
34 extern void SHOWLMP_clear(void);
35
36 // render profiling stuff
37 extern qboolean intimerefresh;
38 extern cvar_t r_speeds2;
39 extern char r_speeds2_string[1024];
40
41 // lighting stuff
42 extern vec3_t lightspot;
43 extern cvar_t r_ambient;
44
45 // model rendering stuff
46 extern float *aliasvert;
47 extern float *aliasvertnorm;
48 extern byte *aliasvertcolor;
49 extern float modelalpha;
50
51 // vis stuff
52 extern cvar_t r_novis;
53
54 // model transform stuff
55 extern cvar_t gl_transform;
56
57 // LordHavoc: 1.0f / N table
58 extern float ixtable[4096];
59
60 #define TOP_RANGE               16                      // soldier uniform colors
61 #define BOTTOM_RANGE    96
62
63 //=============================================================================
64
65 typedef struct entity_render_s
66 {
67         vec3_t  origin;
68         vec3_t  angles;
69
70         int             visframe;               // last frame this entity was found in an active leaf
71
72         model_t *model;                 // NULL = no model
73         int             frame;                  // current desired frame (usually identical to frame2, but frame2 is not always used)
74         int             colormap;               // entity shirt and pants colors
75         int             effects;                // light, particles, etc
76         int             skinnum;                // for Alias models
77         int             flags;                  // render flags
78
79         float   alpha;                  // opacity (alpha) of the model
80         float   scale;                  // size the model is shown
81         float   trail_time;             // last time for trail rendering
82         float   colormod[3];    // color tint for model
83
84         model_t *lerp_model;    // lerp resets when model changes
85         int             frame1;                 // frame that the model is interpolating from
86         int             frame2;                 // frame that the model is interpolating to
87         double  lerp_starttime; // start of this transition
88         double  framelerp;              // interpolation factor, usually computed from lerp_starttime
89         double  frame1start;    // time frame1 began playing (for framegroup animations)
90         double  frame2start;    // time frame2 began playing (for framegroup animations)
91 }
92 entity_render_t;
93
94 typedef struct entity_s
95 {
96         entity_state_t state_baseline;  // baseline for entity
97         entity_state_t state_previous;  // previous state (interpolating from this)
98         entity_state_t state_current;   // current state (interpolating to this)
99
100         entity_render_t render;
101 } entity_t;
102
103 typedef struct
104 {
105         vrect_t         vrect;                          // subwindow in video for refresh
106
107         vec3_t          vieworg;
108         vec3_t          viewangles;
109
110         float           fov_x, fov_y;
111 } refdef_t;
112
113
114 //
115 // refresh
116 //
117
118
119 extern  refdef_t        r_refdef;
120 extern vec3_t   r_origin, vpn, vright, vup;
121 extern qboolean hlbsp;
122
123 void R_Init (void);
124 void R_RenderView (void); // must set r_refdef first
125 void R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect); // called whenever r_refdef or vid change
126
127 // LordHavoc: changed this for sake of GLQuake
128 void R_InitSky (byte *src, int bytesperpixel); // called at level load
129
130 //int R_VisibleCullBox (vec3_t mins, vec3_t maxs);
131
132 void R_NewMap (void);
133
134 #include "r_decals.h"
135
136 void R_ParseParticleEffect (void);
137 void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
138 void R_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent);
139 void R_RocketTrail2 (vec3_t start, vec3_t end, int type, entity_t *ent);
140 void R_SparkShower (vec3_t org, vec3_t dir, int count);
141 void R_BloodPuff (vec3_t org, vec3_t vel, int count);
142 void R_FlameCube (vec3_t mins, vec3_t maxs, int count);
143 void R_Flames (vec3_t org, vec3_t vel, int count);
144
145 void R_EntityParticles (entity_t *ent);
146 void R_BlobExplosion (vec3_t org);
147 void R_ParticleExplosion (vec3_t org, int smoke);
148 void R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength);
149 void R_LavaSplash (vec3_t org);
150 void R_TeleportSplash (vec3_t org);
151
152 void R_NewExplosion(vec3_t org);
153
154 void R_PushDlights (void);
155 void R_DrawWorld (void);
156 //void R_RenderDlights (void);
157 void R_DrawParticles (void);
158 void R_MoveParticles (void);
159 void R_DrawExplosions (void);
160 void R_MoveExplosions (void);
161
162 #include "r_clip.h"
163
164 // LordHavoc: vertex transform
165 #include "transform.h"
166
167 // LordHavoc: transparent polygon system
168 #include "gl_poly.h"
169
170 #define gl_solid_format 3
171 #define gl_alpha_format 4
172
173 //#define PARANOID
174
175 // LordHavoc: was a major time waster
176 #define R_CullBox(mins,maxs) (frustum[0].BoxOnPlaneSideFunc(mins, maxs, &frustum[0]) == 2 || frustum[1].BoxOnPlaneSideFunc(mins, maxs, &frustum[1]) == 2 || frustum[2].BoxOnPlaneSideFunc(mins, maxs, &frustum[2]) == 2 || frustum[3].BoxOnPlaneSideFunc(mins, maxs, &frustum[3]) == 2)
177 #define R_NotCulledBox(mins,maxs) (frustum[0].BoxOnPlaneSideFunc(mins, maxs, &frustum[0]) != 2 && frustum[1].BoxOnPlaneSideFunc(mins, maxs, &frustum[1]) != 2 && frustum[2].BoxOnPlaneSideFunc(mins, maxs, &frustum[2]) != 2 && frustum[3].BoxOnPlaneSideFunc(mins, maxs, &frustum[3]) != 2)
178
179 extern qboolean fogenabled;
180 extern vec3_t fogcolor;
181 extern vec_t fogdensity;
182 //#define calcfog(v) (exp(-(fogdensity*fogdensity*(((v)[0] - r_origin[0]) * vpn[0] + ((v)[1] - r_origin[1]) * vpn[1] + ((v)[2] - r_origin[2]) * vpn[2])*(((v)[0] - r_origin[0]) * vpn[0] + ((v)[1] - r_origin[1]) * vpn[1] + ((v)[2] - r_origin[2]) * vpn[2]))))
183 #define calcfog(v) (exp(-(fogdensity*fogdensity*(((v)[0] - r_origin[0])*((v)[0] - r_origin[0])+((v)[1] - r_origin[1])*((v)[1] - r_origin[1])+((v)[2] - r_origin[2])*((v)[2] - r_origin[2])))))
184 #define calcfogbyte(v) ((byte) (bound(0, ((int) ((float) (calcfog((v)) * 255.0f))), 255)))
185
186 #include "r_modules.h"
187
188 extern qboolean lighthalf;
189
190 #include "r_lerpanim.h"
191
192 void GL_LockArray(int first, int count);
193 void GL_UnlockArray(void);
194
195 void R_DrawBrushModel (entity_t *e);
196 void R_DrawAliasModel (entity_t *ent, int cull, float alpha, model_t *clmodel, frameblend_t *blend, int skin, vec3_t org, vec3_t angles, vec_t scale, int effects, int flags, int colormap);
197 void R_DrawSpriteModel (entity_t *e, frameblend_t *blend);
198
199 void R_ClipSprite (entity_t *e, frameblend_t *blend);
200 void R_Entity_Callback(void *data, void *junk);
201
202 extern cvar_t r_render;
203 extern cvar_t r_upload;
204 extern cvar_t r_ser;
205 #include "image.h"