]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - render.h
strlwr does not exist on Linux
[xonotic/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 #ifndef RENDER_H
22 #define RENDER_H
23
24 // flag arrays used for visibility checking on world model
25 // (all other entities have no per-surface/per-leaf visibility checks)
26 // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_clusters
27 qbyte r_pvsbits[(32768+7)>>3];
28 // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_leafs
29 qbyte r_worldleafvisible[32768];
30 // TODO: dynamic resize according to r_refdef.worldmodel->num_surfaces
31 qbyte r_worldsurfacevisible[262144];
32
33 extern matrix4x4_t r_identitymatrix;
34
35 // 1.0f / N table
36 extern float ixtable[4096];
37
38 // far clip distance for scene
39 extern float r_farclip;
40
41 // fog stuff
42 extern void FOG_clear(void);
43 extern float fog_density, fog_red, fog_green, fog_blue;
44
45 // sky stuff
46 extern cvar_t r_sky;
47 extern cvar_t r_skyscroll1;
48 extern cvar_t r_skyscroll2;
49 extern int skyrendernow, skyrendermasked;
50 extern int R_SetSkyBox(const char *sky);
51 extern void R_SkyStartFrame(void);
52 extern void R_Sky(void);
53 extern void R_ResetSkyBox(void);
54
55 // SHOWLMP stuff (Nehahra)
56 extern void SHOWLMP_decodehide(void);
57 extern void SHOWLMP_decodeshow(void);
58 extern void SHOWLMP_drawall(void);
59 extern void SHOWLMP_clear(void);
60
61 // render profiling stuff
62 extern char r_speeds_string[1024];
63
64 // lighting stuff
65 extern cvar_t r_ambient;
66 extern cvar_t gl_flashblend;
67
68 // vis stuff
69 extern cvar_t r_novis;
70
71 // detail texture stuff
72 extern cvar_t r_detailtextures;
73
74 extern cvar_t r_lerpsprites;
75 extern cvar_t r_lerpmodels;
76 extern cvar_t r_waterscroll;
77 extern cvar_t r_watershader;
78
79 extern cvar_t developer_texturelogging;
80
81 typedef struct rmesh_s
82 {
83         // vertices of this mesh
84         int maxvertices;
85         int numvertices;
86         float *vertex3f;
87         float *svector3f;
88         float *tvector3f;
89         float *normal3f;
90         float *texcoord2f;
91         float *texcoordlightmap2f;
92         float *color4f;
93         // triangles of this mesh
94         int maxtriangles;
95         int numtriangles;
96         int *element3i;
97         int *neighbor3i;
98         // snapping epsilon
99         float epsilon2;
100 }
101 rmesh_t;
102
103 // useful functions for rendering
104 void R_ModulateColors(float *in, float *out, int verts, float r, float g, float b);
105 void R_FillColors(float *out, int verts, float r, float g, float b, float a);
106 int R_Mesh_AddVertex3f(rmesh_t *mesh, const float *v);
107 void R_Mesh_AddPolygon3f(rmesh_t *mesh, int numvertices, float *vertex3f);
108 void R_Mesh_AddBrushMeshFromPlanes(rmesh_t *mesh, int numplanes, mplane_t *planes);
109
110 #define TOP_RANGE               16                      // soldier uniform colors
111 #define BOTTOM_RANGE    96
112
113 //=============================================================================
114
115 extern int r_framecount;
116 extern mplane_t frustum[5];
117
118 extern int c_alias_polys, c_light_polys, c_faces, c_nodes, c_leafs, c_models, c_bmodels, c_sprites, c_particles, c_dlights, c_meshs, c_meshelements, c_rt_lights, c_rt_clears, c_rt_scissored, c_rt_shadowmeshes, c_rt_shadowtris, c_rt_lightmeshes, c_rt_lighttris, c_rtcached_shadowmeshes, c_rtcached_shadowtris, c_bloom, c_bloomcopies, c_bloomcopypixels, c_bloomdraws, c_bloomdrawpixels;
119
120 // brightness of world lightmaps and related lighting
121 // (often reduced when world rtlights are enabled)
122 extern float r_lightmapintensity;
123 // whether to draw world lights realtime, dlights realtime, and their shadows
124 extern qboolean r_rtworld;
125 extern qboolean r_rtworldshadows;
126 extern qboolean r_rtdlight;
127 extern qboolean r_rtdlightshadows;
128
129 // forces all rendering to draw triangle outlines
130 extern cvar_t r_showtris;
131 extern int r_showtrispass;
132
133 //
134 // view origin
135 //
136 extern vec3_t r_vieworigin;
137 extern vec3_t r_viewforward;
138 extern vec3_t r_viewleft;
139 extern vec3_t r_viewright;
140 extern vec3_t r_viewup;
141 extern int r_view_x;
142 extern int r_view_y;
143 extern int r_view_z;
144 extern int r_view_width;
145 extern int r_view_height;
146 extern int r_view_depth;
147 extern float r_view_fov_x;
148 extern float r_view_fov_y;
149 extern matrix4x4_t r_view_matrix;
150
151 extern  mleaf_t         *r_viewleaf, *r_oldviewleaf;
152 extern  unsigned short  d_lightstylevalue[256]; // 8.8 fraction of base light value
153
154 extern  qboolean        envmap;
155
156 extern cvar_t r_drawentities;
157 extern cvar_t r_drawviewmodel;
158 extern cvar_t r_speeds;
159 extern cvar_t r_fullbright;
160 extern cvar_t r_wateralpha;
161 extern cvar_t r_dynamic;
162 extern cvar_t r_drawcollisionbrushes;
163
164 void R_Init(void);
165 void R_UpdateWorld(void); // needs no r_refdef
166 void R_RenderView(void); // must call R_UpdateWorld and set r_refdef first
167
168
169 void R_InitSky (qbyte *src, int bytesperpixel); // called at level load
170
171 void R_WorldVisibility();
172 void R_DrawParticles(void);
173 void R_DrawExplosions(void);
174
175 #define gl_solid_format 3
176 #define gl_alpha_format 4
177
178 int R_CullBox(const vec3_t mins, const vec3_t maxs);
179
180 extern qboolean fogenabled;
181 extern vec3_t fogcolor;
182 extern vec_t fogdensity;
183 #define calcfog(v) (exp(-(fogdensity*fogdensity*(((v)[0] - r_vieworigin[0])*((v)[0] - r_vieworigin[0])+((v)[1] - r_vieworigin[1])*((v)[1] - r_vieworigin[1])+((v)[2] - r_vieworigin[2])*((v)[2] - r_vieworigin[2])))))
184 #define calcfogbyte(v) ((qbyte) (bound(0, ((int) ((float) (calcfog((v)) * 255.0f))), 255)))
185
186 #include "r_modules.h"
187
188 #include "meshqueue.h"
189
190 #include "r_lerpanim.h"
191
192 extern cvar_t r_render;
193 extern cvar_t r_waterwarp;
194
195 extern cvar_t r_textureunits;
196 extern cvar_t gl_polyblend;
197 extern cvar_t gl_dither;
198
199 #include "gl_backend.h"
200
201 #include "r_light.h"
202
203 extern rtexture_t *r_texture_blanknormalmap;
204 extern rtexture_t *r_texture_white;
205 extern rtexture_t *r_texture_black;
206 extern rtexture_t *r_texture_notexture;
207 extern rtexture_t *r_texture_whitecube;
208 extern rtexture_t *r_texture_normalizationcube;
209 #define NUM_DETAILTEXTURES 1
210 extern rtexture_t *r_texture_detailtextures[NUM_DETAILTEXTURES];
211 extern rtexture_t *r_texture_distorttexture[64];
212
213 void R_TimeReport(char *name);
214 void R_TimeReport_Start(void);
215 void R_TimeReport_End(void);
216
217 // r_stain
218 void R_Stain(const vec3_t origin, float radius, int cr1, int cg1, int cb1, int ca1, int cr2, int cg2, int cb2, int ca2);
219
220 void R_DrawWorldCrosshair(void);
221 void R_Draw2DCrosshair(void);
222
223 void R_CalcBeam_Vertex3f(float *vert, const vec3_t org1, const vec3_t org2, float width);
224 void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, int depthdisable, const vec3_t origin, const vec3_t left, const vec3_t up, float scalex1, float scalex2, float scaley1, float scaley2, float cr, float cg, float cb, float ca);
225
226 struct entity_render_s;
227 struct texture_s;
228 struct msurface_s;
229 void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t);
230 void R_UpdateAllTextureInfo(entity_render_t *ent);
231 void R_QueueTextureSurfaceList(entity_render_t *ent, struct texture_s *texture, int texturenumsurfaces, const struct msurface_s **texturesurfacelist, const vec3_t modelorg);
232 void R_DrawSurfaces(entity_render_t *ent, qboolean skysurfaces);
233
234 #endif
235