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

Revision 2763, 1.4 KB checked in by mattausch, 16 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
68        OcclusionQuery *RequestQuery();
69
70        /** Must be called every frame.
71        */
72        void ResetQueries();
73        void DestroyQueries();
74
75protected:
76
77        int mCurrentQueryIdx;
78
79        QueryContainer mOcclusionQueries;
80};
81
82
83} // namespace
84#endif // OcclusionQuery_H
Note: See TracBrowser for help on using the repository browser.