|
|
|
@ -2657,7 +2657,7 @@ void CDriverGL::checkTextureOn() const
|
|
|
|
|
bool CDriverGL::supportOcclusionQuery() const
|
|
|
|
|
{
|
|
|
|
|
H_AUTO_OGL(CDriverGL_supportOcclusionQuery)
|
|
|
|
|
return _Extensions.NVOcclusionQuery;
|
|
|
|
|
return _Extensions.NVOcclusionQuery || _Extensions.ARBOcclusionQuery;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
@ -2688,11 +2688,14 @@ bool CDriverGL::supportFrameBufferObject() const
|
|
|
|
|
IOcclusionQuery *CDriverGL::createOcclusionQuery()
|
|
|
|
|
{
|
|
|
|
|
H_AUTO_OGL(CDriverGL_createOcclusionQuery)
|
|
|
|
|
nlassert(_Extensions.NVOcclusionQuery);
|
|
|
|
|
nlassert(_Extensions.NVOcclusionQuery || _Extensions.ARBOcclusionQuery);
|
|
|
|
|
|
|
|
|
|
#ifndef USE_OPENGLES
|
|
|
|
|
GLuint id;
|
|
|
|
|
nglGenOcclusionQueriesNV(1, &id);
|
|
|
|
|
if (_Extensions.NVOcclusionQuery)
|
|
|
|
|
nglGenOcclusionQueriesNV(1, &id);
|
|
|
|
|
else
|
|
|
|
|
nglGenQueriesARB(1, &id);
|
|
|
|
|
if (id == 0) return NULL;
|
|
|
|
|
COcclusionQueryGL *oqgl = new COcclusionQueryGL;
|
|
|
|
|
oqgl->Driver = this;
|
|
|
|
@ -2719,7 +2722,10 @@ void CDriverGL::deleteOcclusionQuery(IOcclusionQuery *oq)
|
|
|
|
|
oqgl->Driver = NULL;
|
|
|
|
|
nlassert(oqgl->ID != 0);
|
|
|
|
|
GLuint id = oqgl->ID;
|
|
|
|
|
nglDeleteOcclusionQueriesNV(1, &id);
|
|
|
|
|
if (_Extensions.NVOcclusionQuery)
|
|
|
|
|
nglDeleteOcclusionQueriesNV(1, &id);
|
|
|
|
|
else
|
|
|
|
|
nglDeleteQueriesARB(1, &id);
|
|
|
|
|
_OcclusionQueryList.erase(oqgl->Iterator);
|
|
|
|
|
if (oqgl == _CurrentOcclusionQuery)
|
|
|
|
|
{
|
|
|
|
@ -2738,7 +2744,10 @@ void COcclusionQueryGL::begin()
|
|
|
|
|
nlassert(Driver);
|
|
|
|
|
nlassert(Driver->_CurrentOcclusionQuery == NULL); // only one query at a time
|
|
|
|
|
nlassert(ID);
|
|
|
|
|
nglBeginOcclusionQueryNV(ID);
|
|
|
|
|
if (Driver->_Extensions.NVOcclusionQuery)
|
|
|
|
|
nglBeginOcclusionQueryNV(ID);
|
|
|
|
|
else
|
|
|
|
|
nglBeginQueryARB(GL_SAMPLES_PASSED, ID);
|
|
|
|
|
Driver->_CurrentOcclusionQuery = this;
|
|
|
|
|
OcclusionType = NotAvailable;
|
|
|
|
|
VisibleCount = 0;
|
|
|
|
@ -2754,7 +2763,10 @@ void COcclusionQueryGL::end()
|
|
|
|
|
nlassert(Driver);
|
|
|
|
|
nlassert(Driver->_CurrentOcclusionQuery == this); // only one query at a time
|
|
|
|
|
nlassert(ID);
|
|
|
|
|
nglEndOcclusionQueryNV();
|
|
|
|
|
if (Driver->_Extensions.NVOcclusionQuery)
|
|
|
|
|
nglEndOcclusionQueryNV();
|
|
|
|
|
else
|
|
|
|
|
nglEndQueryARB(GL_SAMPLES_PASSED);
|
|
|
|
|
Driver->_CurrentOcclusionQuery = NULL;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
@ -2770,15 +2782,25 @@ IOcclusionQuery::TOcclusionType COcclusionQueryGL::getOcclusionType()
|
|
|
|
|
nlassert(Driver->_CurrentOcclusionQuery != this); // can't query result between a begin/end pair!
|
|
|
|
|
if (OcclusionType == NotAvailable)
|
|
|
|
|
{
|
|
|
|
|
GLuint result;
|
|
|
|
|
// retrieve result
|
|
|
|
|
nglGetOcclusionQueryuivNV(ID, GL_PIXEL_COUNT_AVAILABLE_NV, &result);
|
|
|
|
|
if (result != GL_FALSE)
|
|
|
|
|
if (Driver->_Extensions.NVOcclusionQuery)
|
|
|
|
|
{
|
|
|
|
|
GLuint result;
|
|
|
|
|
// retrieve result
|
|
|
|
|
nglGetOcclusionQueryuivNV(ID, GL_PIXEL_COUNT_AVAILABLE_NV, &result);
|
|
|
|
|
if (result != GL_FALSE)
|
|
|
|
|
{
|
|
|
|
|
nglGetOcclusionQueryuivNV(ID, GL_PIXEL_COUNT_NV, &result);
|
|
|
|
|
OcclusionType = result != 0 ? NotOccluded : Occluded;
|
|
|
|
|
VisibleCount = (uint) result;
|
|
|
|
|
// Note : we could return the exact number of pixels that passed the z-test, but this value is not supported by all implementation (Direct3D ...)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
nglGetOcclusionQueryuivNV(ID, GL_PIXEL_COUNT_NV, &result);
|
|
|
|
|
GLuint result;
|
|
|
|
|
nglGetQueryObjectuivARB(ID, GL_QUERY_RESULT, &result);
|
|
|
|
|
OcclusionType = result != 0 ? NotOccluded : Occluded;
|
|
|
|
|
VisibleCount = (uint) result;
|
|
|
|
|
// Note : we could return the exact number of pixels that passed the z-test, but this value is not supported by all implementation (Direct3D ...)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|