]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/query.h
Add an abstraction for queries
[libs/gl.git] / source / core / query.h
diff --git a/source/core/query.h b/source/core/query.h
new file mode 100644 (file)
index 0000000..aaa993e
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef MSP_GL_QUERY_H_
+#define MSP_GL_QUERY_H_
+
+#include <vector>
+#include <msp/core/noncopyable.h>
+
+namespace Msp {
+namespace GL {
+
+class Renderer;
+
+enum QueryType
+{
+       OCCLUSION_QUERY
+};
+
+class QueryPool: public Msp::NonCopyable
+{
+       friend class Commands;
+
+public:
+       class Activate
+       {
+       private:
+               Renderer &renderer;
+               const QueryPool &pool;
+               unsigned index;
+
+       public:
+               Activate(Renderer &, const QueryPool &, unsigned);
+               ~Activate();
+       };
+
+private:
+       QueryType type;
+       unsigned gl_type;
+       std::vector<unsigned> queries;
+
+public:
+       QueryPool(QueryType type, unsigned);
+       ~QueryPool();
+
+       void resize(unsigned);
+       unsigned get_size() const { return queries.size(); }
+
+       unsigned get_result(unsigned) const;
+};
+
+unsigned get_gl_query_type(QueryType);
+
+} // namespace Msp
+} // namespace GL
+
+#endif