Line data Source code
1 : #ifndef RENDERVA_H_
2 : #define RENDERVA_H_
3 :
4 : class 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 : occludequery *newquery(const void *owner);
58 : private:
59 : class QueryFrame final
60 : {
61 : public:
62 : int cur;
63 :
64 2 : QueryFrame() : cur(0), max(0), defer(0) {}
65 :
66 : void flip();
67 : occludequery *newquery(const void *owner);
68 : void reset();
69 : void cleanup();
70 : private:
71 : static constexpr int maxquery = 2048;
72 :
73 : int max, defer;
74 : std::array<occludequery, maxquery> queries;
75 : };
76 : static constexpr int maxqueryframes = 2;
77 : std::array<QueryFrame, maxqueryframes> queryframes;
78 : uint flipquery = 0;
79 :
80 : occludequery *modelquery = nullptr;
81 : int modelquerybatches = -1,
82 : modelquerymodels = -1,
83 : modelqueryattached = -1;
84 :
85 : };
86 :
87 : extern Occluder occlusionengine;
88 :
89 : extern int oqfrags;
90 :
91 : extern vec shadoworigin, shadowdir;
92 : extern float shadowradius, shadowbias;
93 : extern size_t shadowside;
94 : extern int shadowspot;
95 :
96 : extern vtxarray *visibleva;
97 :
98 : extern void renderrefractmask();
99 : extern void renderalphageom(int side);
100 : extern void rendermapmodels();
101 : extern void renderoutline();
102 : extern bool renderexplicitsky(bool outline = false);
103 : extern bvec outlinecolor;
104 :
105 : extern int deferquery;
106 : extern void startbb(bool mask = true);
107 : extern void endbb(bool mask = true);
108 : extern void drawbb(const ivec &bo, const ivec &br);
109 :
110 : extern void renderdecals();
111 :
112 : struct shadowmesh;
113 : extern void clearshadowmeshes();
114 : extern void genshadowmeshes();
115 : extern shadowmesh *findshadowmesh(int idx, const extentity &e);
116 : extern void rendershadowmesh(const shadowmesh *m);
117 : extern void dynamicshadowvabounds(int mask, vec &bbmin, vec &bbmax);
118 :
119 : #endif
|