Commit 99a25cfb authored by hybrid's avatar hybrid

Remove debug output, add ifdefs for OpenGL versions not supporting...

Remove debug output, add ifdefs for OpenGL versions not supporting ARB_occlusion_query. Add support for NV_occlusion query.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3266 dfc29bdd-3216-0410-991c-e03cc46cb475
parent ccd1a241
......@@ -1274,7 +1274,6 @@ void CD3D9Driver::runOcclusionQuery(scene::ISceneNode* node, bool visible)
const s32 index = OcclusionQueries.linear_search(SOccQuery(node));
if (index != -1)
{
os::Printer::log("Start query", core::stringc(reinterpret_cast<u32>(OcclusionQueries[index].ID)));
if (OcclusionQueries[index].ID)
reinterpret_cast<IDirect3DQuery9*>(OcclusionQueries[index].ID)->Issue(D3DISSUE_BEGIN);
CNullDriver::runOcclusionQuery(node,visible);
......@@ -1310,10 +1309,7 @@ void CD3D9Driver::updateOcclusionQuery(scene::ISceneNode* node, bool block)
} while (!available);
}
if (available)
{
OcclusionQueries[index].Result = tmp;
os::Printer::log("Occ result", core::stringc(tmp));
}
}
}
......
......@@ -1268,12 +1268,22 @@ void COpenGLDriver::runOcclusionQuery(scene::ISceneNode* node, bool visible)
const s32 index = OcclusionQueries.linear_search(SOccQuery(node));
if (index != -1)
{
os::Printer::log("Start query", core::stringc(reinterpret_cast<GLuint>(OcclusionQueries[index].ID)));
if (OcclusionQueries[index].ID)
extGlBeginQuery(GL_SAMPLES_PASSED_ARB, reinterpret_cast<GLuint>(OcclusionQueries[index].ID));
extGlBeginQuery(
#ifdef GL_ARB_occlusion_query
GL_SAMPLES_PASSED_ARB,
#else
0,
#endif
reinterpret_cast<GLuint>(OcclusionQueries[index].ID));
CNullDriver::runOcclusionQuery(node,visible);
if (OcclusionQueries[index].ID)
extGlEndQuery(GL_SAMPLES_PASSED_ARB);
extGlEndQuery(
#ifdef GL_ARB_occlusion_query
GL_SAMPLES_PASSED_ARB);
#else
0);
#endif
testGLError();
}
}
......@@ -1284,7 +1294,6 @@ void COpenGLDriver::runOcclusionQuery(scene::ISceneNode* node, bool visible)
Update might not occur in this case, though */
void COpenGLDriver::updateOcclusionQuery(scene::ISceneNode* node, bool block)
{
const s32 index = OcclusionQueries.linear_search(SOccQuery(node));
if (index != -1)
{
......@@ -1294,16 +1303,28 @@ void COpenGLDriver::updateOcclusionQuery(scene::ISceneNode* node, bool block)
GLint available = block?GL_TRUE:GL_FALSE;
if (!block)
extGlGetQueryObjectiv(reinterpret_cast<GLuint>(OcclusionQueries[index].ID),
#ifdef GL_ARB_occlusion_query
GL_QUERY_RESULT_AVAILABLE_ARB,
#elif defined(GL_NV_occlusion_query)
GL_PIXEL_COUNT_AVAILABLE_NV,
#else
0,
#endif
&available);
testGLError();
if (available==GL_TRUE)
{
extGlGetQueryObjectiv(reinterpret_cast<GLuint>(OcclusionQueries[index].ID),
#ifdef GL_ARB_occlusion_query
GL_QUERY_RESULT_ARB,
#elif defined(GL_NV_occlusion_query)
GL_PIXEL_COUNT_NV,
#else
0,
#endif
&available);
OcclusionQueries[index].Result = available;
os::Printer::log("Occ result", core::stringc(available));
if (queryFeature(EVDF_OCCLUSION_QUERY))
OcclusionQueries[index].Result = available;
}
testGLError();
}
......
......@@ -672,10 +672,17 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
OcclusionQuerySupport=(num>0);
}
else
#endif
#ifdef GL_NV_occlusion_query
if (FeatureAvailable[IRR_NV_occlusion_query])
{
glGetIntegerv(GL_PIXEL_COUNTER_BITS_NV, &num);
OcclusionQuerySupport=(num>0);
}
else
#endif
OcclusionQuerySupport=false;
#ifdef _DEBUG
if (FeatureAvailable[IRR_NVX_gpu_memory_info])
{
......
......@@ -2108,6 +2108,8 @@ inline void COpenGLExtensionHandler::extGlGenQueries(GLsizei n, GLuint *ids)
pGlGenQueriesARB(n, ids);
#elif defined(GL_ARB_occlusion_query)
glGenQueriesARB(n, ids);
#elif defined(GL_NV_occlusion_query)
glGenOcclusionQueriesNV(n, ids);
#else
os::Printer::log("glGenQueriesARB not supported", ELL_ERROR);
#endif
......@@ -2120,6 +2122,8 @@ inline void COpenGLExtensionHandler::extGlDeleteQueries(GLsizei n, const GLuint
pGlDeleteQueriesARB(n, ids);
#elif defined(GL_ARB_occlusion_query)
glDeleteQueriesARB(n, ids);
#elif defined(GL_NV_occlusion_query)
glDeleteOcclusionQueriesNV(n, ids);
#else
os::Printer::log("glDeleteQueriesARB not supported", ELL_ERROR);
#endif
......@@ -2132,6 +2136,8 @@ inline GLboolean COpenGLExtensionHandler::extGlIsQuery(GLuint id)
return pGlIsQueryARB(id);
#elif defined(GL_ARB_occlusion_query)
return glIsQueryARB(id);
#elif defined(GL_NV_occlusion_query)
glIsOcclusionQueryNV(id);
#else
return false;
#endif
......@@ -2144,6 +2150,8 @@ inline void COpenGLExtensionHandler::extGlBeginQuery(GLenum target, GLuint id)
pGlBeginQueryARB(target, id);
#elif defined(GL_ARB_occlusion_query)
glBeginQueryARB(target, id);
#elif defined(GL_NV_occlusion_query)
glBeginOcclusionQueryNV(id);
#else
os::Printer::log("glBeginQueryARB not supported", ELL_ERROR);
#endif
......@@ -2156,6 +2164,8 @@ inline void COpenGLExtensionHandler::extGlEndQuery(GLenum target)
pGlEndQueryARB(target);
#elif defined(GL_ARB_occlusion_query)
glEndQueryARB(target);
#elif defined(GL_NV_occlusion_query)
glEndOcclusionQueryNV();
#else
os::Printer::log("glEndQueryARB not supported", ELL_ERROR);
#endif
......@@ -2180,8 +2190,10 @@ inline void COpenGLExtensionHandler::extGlGetQueryObjectiv(GLuint id, GLenum pna
pGlGetQueryObjectivARB(id, pname, params);
#elif defined(GL_ARB_occlusion_query)
glGetQueryObjectivARB(id, pname, params);
#elif defined(GL_NV_occlusion_query)
glGetOcclusionQueryivNV(id, pname, params);
#else
os::Printer::log("glGetQueryObjectivARB not supported", ELL_ERROR);
os::Printer::log("glGetQueryObjectiv not supported", ELL_ERROR);
#endif
}
......@@ -2192,8 +2204,10 @@ inline void COpenGLExtensionHandler::extGlGetQueryObjectuiv(GLuint id, GLenum pn
pGlGetQueryObjectuivARB(id, pname, params);
#elif defined(GL_ARB_occlusion_query)
glGetQueryObjectuivARB(id, pname, params);
#elif defined(GL_NV_occlusion_query)
glGetOcclusionQueryuivNV(id, pname, params);
#else
os::Printer::log("glGetQueryObjectuivARB not supported", ELL_ERROR);
os::Printer::log("glGetQueryObjectuiv not supported", ELL_ERROR);
#endif
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment