| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #include "anki/gl/Query.h"
- #include "anki/util/Exception.h"
- #include "anki/util/Assert.h"
- #include <GL/glew.h>
- namespace anki {
- //==============================================================================
- // QueryImpl =
- //==============================================================================
- /// XXX
- struct QueryImpl
- {
- GLuint glId;
- GLenum question;
- };
- //==============================================================================
- // Query =
- //==============================================================================
- //==============================================================================
- Query::Query(QueryQuestion q)
- {
- impl.reset(new QueryImpl);
- // question
- switch(q)
- {
- case QQ_SAMPLES_PASSED:
- impl->question = GL_SAMPLES_PASSED;
- break;
- default:
- ANKI_ASSERT(0);
- };
- // glId
- glGenQueries(1, &impl->glId);
- if(impl->glId == 0)
- {
- throw ANKI_EXCEPTION("Query generation failed");
- }
- }
- //==============================================================================
- Query::~Query()
- {
- glDeleteQueries(1, &impl->glId);
- }
- //==============================================================================
- void Query::beginQuery()
- {
- glBeginQuery(impl->question, impl->glId);
- }
- //==============================================================================
- void Query::endQuery()
- {
- glEndQuery(impl->question);
- }
- } // end namespace anki
|