Line data Source code
1 : #ifndef RENDERVA_H_
2 : #define RENDERVA_H_
3 :
4 : struct vtxarray;
5 :
6 : enum OcclusionLevels
7 : {
8 : Occlude_Nothing = 0,
9 : Occlude_Geom,
10 : Occlude_BB,
11 : Occlude_Parent
12 : };
13 :
14 : class vfc final
15 : {
16 : public:
17 : int isfoggedcube(const ivec &o, int size) const;
18 : int isvisiblecube(const ivec &o, int size) const;
19 : void visiblecubes(bool cull = true);
20 : bool isfoggedsphere(float rad, const vec &cv) const;
21 : int isvisiblesphere(float rad, const vec &cv) const;
22 : int isvisiblebb(const ivec &bo, const ivec &br) const;
23 : int cullfrustumsides(const vec &lightpos, float lightradius, float size, float border);
24 : private:
25 : static constexpr uint numvfc = 5;
26 : void calcvfcD();
27 : void setvfcP(const vec &bbmin = vec(-1, -1, -1), const vec &bbmax = vec(1, 1, 1));
28 :
29 : std::array<plane, numvfc> vfcP; // perpindictular vectors to view frustrum bounding planes
30 : float vfcDfog; // far plane culling distance (fog limit).
31 : std::array<float, numvfc> vfcDnear,
32 : vfcDfar;
33 : };
34 :
35 : extern vfc view;
36 :
37 : struct occludequery final
38 : {
39 : const void *owner;
40 : GLuint id;
41 : int fragments;
42 :
43 : void startquery() const;
44 : };
45 :
46 : class Occluder final
47 : {
48 : public:
49 : void setupmodelquery(occludequery *q);
50 : void clearqueries();
51 : void flipqueries();
52 : void endquery() const;
53 : void endmodelquery(); // starts the model query (!)
54 : bool checkquery(occludequery *query, bool nowait = false);
55 : void resetqueries();
56 : int getnumqueries() const;
57 0 : occludequery *newquery(const void *owner)
58 : {
59 0 : return queryframes[flipquery].newquery(owner);
60 : }
61 : private:
62 : class queryframe
63 : {
64 : public:
65 : int cur;
66 :
67 2 : queryframe() : cur(0), max(0), defer(0) {}
68 :
69 : void flip();
70 : occludequery *newquery(const void *owner);
71 : void reset();
72 : void cleanup();
73 : private:
74 : static constexpr int maxquery = 2048;
75 :
76 : int max, defer;
77 : std::array<occludequery, maxquery> queries;
78 : };
79 : static constexpr int maxqueryframes = 2;
80 : std::array<queryframe, maxqueryframes> queryframes;
81 : uint flipquery = 0;
82 :
83 : occludequery *modelquery = nullptr;
84 : int modelquerybatches = -1,
85 : modelquerymodels = -1,
86 : modelqueryattached = -1;
87 :
88 : };
89 :
90 : extern Occluder occlusionengine;
91 :
92 :
93 : extern int oqfrags;
94 :
95 : extern vec shadoworigin, shadowdir;
96 : extern float shadowradius, shadowbias;
97 : extern size_t shadowside;
98 : extern int shadowspot;
99 :
100 : extern vtxarray *visibleva;
101 :
102 : extern void renderrefractmask();
103 : extern void renderalphageom(int side);
104 : extern void rendermapmodels();
105 : extern void renderoutline();
106 : extern bool renderexplicitsky(bool outline = false);
107 : extern bvec outlinecolor;
108 :
109 : extern int deferquery;
110 : extern void startbb(bool mask = true);
111 : extern void endbb(bool mask = true);
112 : extern void drawbb(const ivec &bo, const ivec &br);
113 :
114 : extern void renderdecals();
115 :
116 : struct shadowmesh;
117 : extern void clearshadowmeshes();
118 : extern void genshadowmeshes();
119 : extern shadowmesh *findshadowmesh(int idx, const extentity &e);
120 : extern void rendershadowmesh(const shadowmesh *m);
121 : extern void dynamicshadowvabounds(int mask, vec &bbmin, vec &bbmax);
122 :
123 : #endif
|