]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - client.h
Refactor the code to make r_view and r_viewcache members of r_refdef,
[xonotic/darkplaces.git] / client.h
index 0e3163d1f20310e954b8e8b63d2312f2aef083bb..bc1952fcae990114cc7413f9e29c2e214c67b47b 100644 (file)
--- a/client.h
+++ b/client.h
@@ -1347,6 +1347,83 @@ typedef struct r_refdef_stats_s
 }
 r_refdef_stats_t;
 
+typedef struct r_refdef_view_s
+{
+       // view information (changes multiple times per frame)
+       // if any of these variables change then r_refdef.viewcache must be regenerated
+       // by calling R_View_Update
+       // (which also updates viewport, scissor, colormask)
+
+       // it is safe and expected to copy this into a structure on the stack and
+       // call the renderer recursively, then restore from the stack afterward
+       // (as long as R_View_Update is called)
+
+       // eye position information
+       matrix4x4_t matrix, inverse_matrix;
+       vec3_t origin;
+       vec3_t forward;
+       vec3_t left;
+       vec3_t right;
+       vec3_t up;
+       int numfrustumplanes;
+       mplane_t frustum[6];
+       qboolean useclipplane;
+       qboolean usecustompvs; // uses r_refdef.viewcache.pvsbits as-is rather than computing it
+       mplane_t clipplane;
+       float frustum_x, frustum_y;
+       vec3_t frustumcorner[4];
+       // if turned off it renders an ortho view
+       int useperspective;
+       float ortho_x, ortho_y;
+
+       // screen area to render in
+       int x;
+       int y;
+       int z;
+       int width;
+       int height;
+       int depth;
+
+       // which color components to allow (for anaglyph glasses)
+       int colormask[4];
+
+       // global RGB color multiplier for rendering, this is required by HDR
+       float colorscale;
+
+       // whether to call R_ClearScreen before rendering stuff
+       qboolean clear;
+
+       // whether to draw r_showtris and such, this is only true for the main
+       // view render, all secondary renders (HDR, mirrors, portals, cameras,
+       // distortion effects, etc) omit such debugging information
+       qboolean showdebug;
+
+       // these define which values to use in GL_CullFace calls to request frontface or backface culling
+       int cullface_front;
+       int cullface_back;
+}
+r_refdef_view_t;
+
+typedef struct r_refdef_viewcache_s
+{
+       // these properties are generated by R_View_Update()
+
+       // which entities are currently visible for this viewpoint
+       // (the used range is 0...r_refdef.numentities)
+       unsigned char entityvisible[MAX_EDICTS];
+       // flag arrays used for visibility checking on world model
+       // (all other entities have no per-surface/per-leaf visibility checks)
+       // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_clusters
+       unsigned char world_pvsbits[(32768+7)>>3]; // FIXME: buffer overflow on huge maps
+       // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_leafs
+       unsigned char world_leafvisible[32768]; // FIXME: buffer overflow on huge maps
+       // TODO: dynamic resize according to r_refdef.worldmodel->num_surfaces
+       unsigned char world_surfacevisible[262144]; // FIXME: buffer overflow on huge maps
+       // if true, the view is currently in a leaf without pvs data
+       qboolean world_novis;
+}
+r_refdef_viewcache_t;
+
 typedef struct r_refdef_s
 {
        // these fields define the basic rendering information for the world
@@ -1357,6 +1434,10 @@ typedef struct r_refdef_s
        // frustum_x/frustum_y are calculated
        float frustumscale_x, frustumscale_y;
 
+       // current view settings (these get reset a few times during rendering because of water rendering, reflections, etc)
+       r_refdef_view_t view;
+       r_refdef_viewcache_t viewcache;
+
        // minimum visible distance (pixels closer than this disappear)
        double nearclip;
        // maximum visible distance (pixels further than this disappear in 16bpp modes,
@@ -1434,86 +1515,7 @@ typedef struct r_refdef_s
 }
 r_refdef_t;
 
-typedef struct r_view_s
-{
-       // view information (changes multiple times per frame)
-       // if any of these variables change then r_viewcache must be regenerated
-       // by calling R_View_Update
-       // (which also updates viewport, scissor, colormask)
-
-       // it is safe and expected to copy this into a structure on the stack and
-       // call the renderer recursively, then restore from the stack afterward
-       // (as long as R_View_Update is called)
-
-       // eye position information
-       matrix4x4_t matrix, inverse_matrix;
-       vec3_t origin;
-       vec3_t forward;
-       vec3_t left;
-       vec3_t right;
-       vec3_t up;
-       int numfrustumplanes;
-       mplane_t frustum[6];
-       qboolean useclipplane;
-       qboolean usecustompvs; // uses r_viewcache.pvsbits as-is rather than computing it
-       mplane_t clipplane;
-       float frustum_x, frustum_y;
-       vec3_t frustumcorner[4];
-       // if turned off it renders an ortho view
-       int useperspective;
-       float ortho_x, ortho_y;
-
-       // screen area to render in
-       int x;
-       int y;
-       int z;
-       int width;
-       int height;
-       int depth;
-
-       // which color components to allow (for anaglyph glasses)
-       int colormask[4];
-
-       // global RGB color multiplier for rendering, this is required by HDR
-       float colorscale;
-
-       // whether to call R_ClearScreen before rendering stuff
-       qboolean clear;
-
-       // whether to draw r_showtris and such, this is only true for the main
-       // view render, all secondary renders (HDR, mirrors, portals, cameras,
-       // distortion effects, etc) omit such debugging information
-       qboolean showdebug;
-
-       // these define which values to use in GL_CullFace calls to request frontface or backface culling
-       int cullface_front;
-       int cullface_back;
-}
-r_view_t;
-
-typedef struct r_viewcache_s
-{
-       // these properties are generated by R_View_Update()
-
-       // which entities are currently visible for this viewpoint
-       // (the used range is 0...r_refdef.numentities)
-       unsigned char entityvisible[MAX_EDICTS];
-       // flag arrays used for visibility checking on world model
-       // (all other entities have no per-surface/per-leaf visibility checks)
-       // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_clusters
-       unsigned char world_pvsbits[(32768+7)>>3]; // FIXME: buffer overflow on huge maps
-       // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_leafs
-       unsigned char world_leafvisible[32768]; // FIXME: buffer overflow on huge maps
-       // TODO: dynamic resize according to r_refdef.worldmodel->num_surfaces
-       unsigned char world_surfacevisible[262144]; // FIXME: buffer overflow on huge maps
-       // if true, the view is currently in a leaf without pvs data
-       qboolean world_novis;
-}
-r_viewcache_t;
-
 extern r_refdef_t r_refdef;
-extern r_view_t r_view;
-extern r_viewcache_t r_viewcache;
 
 #endif