2 #include <msp/gl/extensions/arb_occlusion_query.h>
3 #include <msp/gl/extensions/arb_occlusion_query2.h>
5 #include "query_backend.h"
12 OpenGLQueryPool::OpenGLQueryPool(unsigned t):
13 gl_type(get_gl_query_type(t))
15 if(t==OCCLUSION_QUERY)
17 static Require req(ARB_occlusion_query);
18 static Require req2(ARB_occlusion_query2);
22 OpenGLQueryPool::OpenGLQueryPool(OpenGLQueryPool &&other):
23 gl_type(other.gl_type),
24 queries(move(other.queries))
26 other.queries.clear();
29 OpenGLQueryPool::~OpenGLQueryPool()
31 glDeleteQueries(queries.size(), queries.data());
34 void OpenGLQueryPool::resize()
36 unsigned size = static_cast<const QueryPool *>(this)->size;
37 if(size<queries.size())
38 glDeleteQueries(queries.size()-size, queries.data()+size);
40 unsigned old_size = queries.size();
43 glGenQueries(size-old_size, queries.data()+old_size);
46 unsigned OpenGLQueryPool::get_result(unsigned i) const
49 glGetQueryObjectuiv(queries[i], GL_QUERY_RESULT, &result);
54 unsigned get_gl_query_type(unsigned t)
58 case OCCLUSION_QUERY: return GL_ANY_SAMPLES_PASSED;
59 default: throw invalid_argument("get_gl_query_type");