]> git.tdb.fi Git - libs/gl.git/blob - source/core/query.h
Add an abstraction for queries
[libs/gl.git] / source / core / query.h
1 #ifndef MSP_GL_QUERY_H_
2 #define MSP_GL_QUERY_H_
3
4 #include <vector>
5 #include <msp/core/noncopyable.h>
6
7 namespace Msp {
8 namespace GL {
9
10 class Renderer;
11
12 enum QueryType
13 {
14         OCCLUSION_QUERY
15 };
16
17 class QueryPool: public Msp::NonCopyable
18 {
19         friend class Commands;
20
21 public:
22         class Activate
23         {
24         private:
25                 Renderer &renderer;
26                 const QueryPool &pool;
27                 unsigned index;
28
29         public:
30                 Activate(Renderer &, const QueryPool &, unsigned);
31                 ~Activate();
32         };
33
34 private:
35         QueryType type;
36         unsigned gl_type;
37         std::vector<unsigned> queries;
38
39 public:
40         QueryPool(QueryType type, unsigned);
41         ~QueryPool();
42
43         void resize(unsigned);
44         unsigned get_size() const { return queries.size(); }
45
46         unsigned get_result(unsigned) const;
47 };
48
49 unsigned get_gl_query_type(QueryType);
50
51 } // namespace Msp
52 } // namespace GL
53
54 #endif