7 #include <gls/headercheck.hpp>
8 #include <gls/errorcheck.hpp>
9 #include <gls/objects/object.hpp>
15 void gen_queries( GLsizei size, GLuint* name ) { glGenQueries( size, name ); }
16 void delete_queries( GLsizei size,
const GLuint* name ) { glDeleteQueries( size, name ); }
25 template<GLenum Target>
35 return m_object.name();
52 void run( T callable ) {
60 check_gl_error( glBeginQuery( Target, m_object.name() ) );
62 check_gl_error( glEndQuery( Target ) );
79 check_gl_error( glBeginQuery( Target, m_object.name() ) );
90 check_gl_error( glEndQuery( Target ) );
106 if( m_waiting && !ready() ) {
110 check_gl_error( glGetQueryObjectiv(
name(), GL_QUERY_RESULT, &result ) );
128 if( m_waiting && !ready() ) {
132 check_gl_error( glGetQueryObjectuiv(
name(), GL_QUERY_RESULT, &result ) );
139 auto result_ready = GLuint();
141 check_gl_error( glGetQueryObjectuiv(
name(), GL_QUERY_RESULT_AVAILABLE, &result_ready ) );
143 m_waiting = ( result_ready == GL_FALSE );
145 return result_ready == GL_TRUE;
148 object<priv::gen_queries, priv::delete_queries> m_object;
149 bool m_waiting =
false;
void run(T callable)
Run the query on the provided callable.
Definition: query.hpp:52
void end()
Mark the end of the query block.
Definition: query.hpp:89
bool poll_result(GLuint &result)
Poll the result of the query.
Definition: query.hpp:127
GLuint name() const
Retrieve the OpenGL name of this query.
Definition: query.hpp:34
Class encapsulating an OpenGL query object.
Definition: query.hpp:26
bool poll_result(GLint &result)
Poll the result of the query.
Definition: query.hpp:105
void begin()
Mark the begin of the query block.
Definition: query.hpp:72
Definition: buffer.hpp:12