source: GTP/trunk/App/Demos/Vis/CHC_revisited/OcclusionQuery.h @ 2765

Revision 2765, 1.5 KB checked in by mattausch, 17 years ago (diff)
Line 
1#ifndef _OcclusionQuery_H__
2#define _OcclusionQuery_H__
3
4#include <vector>
5#include "common.h"
6
7
8namespace CHCDemo
9{
10
11class BvhNode;
12
13/** This class is an implementation for single node queries and multiqueries.
14        @remark the class encapsulates hardware occlusion query calls.
15*/
16class OcclusionQuery
17{
18public:
19       
20        OcclusionQuery();
21
22        virtual ~OcclusionQuery();
23
24        bool ResultAvailable() const;
25       
26        unsigned int GetQueryResult() const;
27       
28        void BeginQuery();
29       
30        void EndQuery();
31       
32        unsigned int GetQueryId() const;
33        /** Returns the first added node.
34        */
35        inline BvhNode *GetFrontNode() const { return mNodes[0]; }
36        /** Reset the contents of this query.
37        */
38        inline void Reset() { mNodes.clear(); }
39        /** Adds a node to the query.
40        */
41        inline void AddNode(BvhNode *node) { mNodes.push_back(node); }
42
43
44protected:
45
46        OcclusionQuery(unsigned int id);
47       
48       
49        ////////////
50        //-- members
51
52        float mPFail;
53        /// all nodes that are tested with the same query
54        BvhNodeContainer mNodes;
55        // the query associated with this test
56        unsigned int mQueryId;
57        /// type of the query
58        bool mIsVisibleQuery;
59};
60
61
62class QueryHandler
63{
64public:
65
66        QueryHandler();
67        ~QueryHandler() { DestroyQueries(); }
68
69        OcclusionQuery *RequestQuery();
70
71        /** Must be called every frame.
72        */
73        void ResetQueries();
74        /** Destroys all the queries.
75        */
76        void DestroyQueries();
77
78protected:
79
80        int mCurrentQueryIdx;
81
82        QueryContainer mOcclusionQueries;
83};
84
85
86} // namespace
87#endif // OcclusionQuery_H
Note: See TracBrowser for help on using the repository browser.