| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
- // All rights reserved.
- // Code licensed under the BSD License.
- // http://www.anki3d.org/LICENSE
- #include <AnKi/Gr/gl/OcclusionQueryImpl.h>
- namespace anki
- {
- void OcclusionQueryImpl::init()
- {
- glGenQueries(1, &m_glName);
- ANKI_ASSERT(m_glName != 0);
- }
- void OcclusionQueryImpl::begin()
- {
- ANKI_ASSERT(isCreated());
- glBeginQuery(GL_ANY_SAMPLES_PASSED_CONSERVATIVE, m_glName);
- }
- void OcclusionQueryImpl::end()
- {
- ANKI_ASSERT(isCreated());
- glEndQuery(GL_ANY_SAMPLES_PASSED_CONSERVATIVE);
- }
- OcclusionQueryResult OcclusionQueryImpl::getResult() const
- {
- ANKI_ASSERT(isCreated());
- OcclusionQueryResult result = OcclusionQueryResult::NOT_AVAILABLE;
- GLuint params;
- glGetQueryObjectuiv(m_glName, GL_QUERY_RESULT_AVAILABLE, ¶ms);
- if(params != 0)
- {
- glGetQueryObjectuiv(m_glName, GL_QUERY_RESULT, ¶ms);
- result = (params == 1) ? OcclusionQueryResult::VISIBLE : OcclusionQueryResult::NOT_VISIBLE;
- }
- return result;
- }
- } // end namespace anki
|