a big change with a little description...
[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 #define MAXCLIPPLANES   11
24
25 #define TOP_RANGE               16                      // soldier uniform colors
26 #define BOTTOM_RANGE    96
27
28 //=============================================================================
29
30 typedef struct efrag_s
31 {
32         struct mleaf_s          *leaf;
33         struct efrag_s          *leafnext;
34         struct entity_s         *entity;
35         struct efrag_s          *entnext;
36 } efrag_t;
37
38 #define RENDER_STEP 1
39 #define RENDER_GLOWTRAIL 2
40 #define RENDER_VIEWMODEL 4
41
42 // LordHavoc: made this more compact, and added some more fields
43 typedef struct
44 {
45         double  time; // time this state was updated
46         vec3_t  origin;
47         vec3_t  angles;
48         int             effects;
49         unsigned short modelindex;
50         unsigned short frame;
51         byte    colormap;
52         byte    skin;
53         byte    alpha;
54         byte    scale;
55         byte    glowsize;
56         byte    glowcolor;
57         byte    colormod;
58         byte    flags;
59 } entity_state_t;
60
61 typedef struct entity_s
62 {
63         entity_state_t                  state_baseline; // baseline for entity
64         entity_state_t                  state_previous; // previous state (interpolating from this)
65         entity_state_t                  state_current;  // current state (interpolating to this)
66
67         struct
68         {
69                 vec3_t                                  origin;
70                 vec3_t                                  angles; 
71
72                 // LordHavoc: added support for alpha transprency and other effects
73                 float                                   alpha;                  // opacity (alpha) of the model
74                 float                                   colormod[3];    // color tint for model
75                 float                                   scale;                  // size the model is shown
76                 float                                   glowsize;               // how big the glow is
77                 byte                                    glowcolor;              // color of glow and particle trail (paletted)
78                 byte                                    flags;                  // render flags
79
80                 struct model_s                  *model;                 // NULL = no model
81                 int                                             frame;                  // current desired frame (usually identical to frame2, but frame2 is not always used)
82                 struct efrag_s                  *efrag;                 // linked list of efrags
83                 int                                             colormap;
84                 int                                             effects;                // light, particles, etc
85                 int                                             skinnum;                // for Alias models
86
87                 int                                             visframe;               // last frame this entity was found in an active leaf
88
89                 struct model_s                  *lerp_model;    // lerp resets when model changes
90                 float                                   lerp_starttime; // start of this transition
91                 int                                             frame1;                 // frame that the model is interpolating from
92                 int                                             frame2;                 // frame that the model is interpolating to
93                 double                                  framelerp;              // interpolation factor, usually computed from lerp_starttime
94                 double                                  frame1start;    // time frame1 began playing (for framegroup animations)
95                 double                                  frame2start;    // time frame2 began playing (for framegroup animations)
96 //              float                                   syncbase;               // for client-side animations
97
98                 int                                             dlightframe;    // dynamic lighting
99                 int                                             dlightbits[8];
100                 
101                 float                                   trail_time;
102         // FIXME: could turn these into a union
103 //              int                                             trivial_accept;
104                 struct mnode_s                  *topnode;               // for bmodels, first world node
105                                                                                                 //  that splits bmodel, or NULL if
106                                                                                                 //  not split
107         }
108         render;
109 } entity_t;
110
111 // !!! if this is changed, it must be changed in asm_draw.h too !!!
112 typedef struct
113 {
114         vrect_t         vrect;                          // subwindow in video for refresh
115                                                                         // FIXME: not need vrect next field here?
116         /*
117         vrect_t         aliasvrect;                     // scaled Alias version
118         int                     vrectright, vrectbottom;        // right & bottom screen coords
119         int                     aliasvrectright, aliasvrectbottom;      // scaled Alias versions
120         float           vrectrightedge;                 // rightmost right edge we care about,
121                                                                                 //  for use in edge list
122         float           fvrectx, fvrecty;               // for floating-point compares
123         float           fvrectx_adj, fvrecty_adj; // left and top edges, for clamping
124         int                     vrect_x_adj_shift20;    // (vrect.x + 0.5 - epsilon) << 20
125         int                     vrectright_adj_shift20; // (vrectright + 0.5 - epsilon) << 20
126         float           fvrectright_adj, fvrectbottom_adj;
127                                                                                 // right and bottom edges, for clamping
128         float           fvrectright;                    // rightmost edge, for Alias clamping
129         float           fvrectbottom;                   // bottommost edge, for Alias clamping
130         float           horizontalFieldOfView;  // at Z = 1.0, this many X is visible 
131                                                                                 // 2.0 = 90 degrees
132         float           xOrigin;                        // should probably always be 0.5
133         float           yOrigin;                        // between be around 0.3 to 0.5
134         */
135
136         vec3_t          vieworg;
137         vec3_t          viewangles;
138         
139         float           fov_x, fov_y;
140
141 //      int                     ambientlight;
142 } refdef_t;
143
144
145 //
146 // refresh
147 //
148
149
150 extern  refdef_t        r_refdef;
151 extern vec3_t   r_origin, vpn, vright, vup;
152
153 extern  struct texture_s        *r_notexture_mip;
154
155 void R_Init (void);
156 void R_InitTextures (void);
157 void R_InitEfrags (void);
158 void R_RenderView (void);               // must set r_refdef first
159 void R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect);
160                                                                 // called whenever r_refdef or vid change
161 // LordHavoc: changed this for sake of GLQuake
162 void R_InitSky (byte *src, int bytesperpixel);  // called at level load
163 //void R_InitSky (struct texture_s *mt);        // called at level load
164
165 void R_AddEfrags (entity_t *ent);
166 void R_RemoveEfrags (entity_t *ent);
167
168 void R_NewMap (void);
169
170 #include "r_decals.h"
171
172 void R_ParseParticleEffect (void);
173 void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
174 void R_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent);
175 void R_RocketTrail2 (vec3_t start, vec3_t end, int type, entity_t *ent);
176 void R_SparkShower (vec3_t org, vec3_t dir, int count);
177 void R_BloodPuff (vec3_t org, vec3_t vel, int count);
178 void R_FlameCube (vec3_t mins, vec3_t maxs, int count);
179 void R_Flames (vec3_t org, vec3_t vel, int count);
180
181 void R_EntityParticles (entity_t *ent);
182 void R_BlobExplosion (vec3_t org);
183 void R_ParticleExplosion (vec3_t org, int smoke);
184 void R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength);
185 void R_LavaSplash (vec3_t org);
186 void R_TeleportSplash (vec3_t org);
187
188 void R_NewExplosion(vec3_t org);
189
190 void R_PushDlights (void);
191 void R_DrawWorld (void);
192 //void R_RenderDlights (void);
193 void R_DrawParticles (void);
194 void R_MoveParticles (void);
195 void R_DrawExplosions (void);
196 void R_MoveExplosions (void);