Added GL token mappings for standard GL errors numbers for when no GLU is available

This commit is contained in:
Robert Osfield 2009-11-09 11:36:54 +00:00
parent 7fb88a83ff
commit d515b69d88
2 changed files with 67 additions and 24 deletions

View File

@ -1088,7 +1088,24 @@ bool State::checkGLErrors(const char* str) const
if (error) osg::notify(WARN)<<"Warning: detected OpenGL error '" << error<<"'"; if (error) osg::notify(WARN)<<"Warning: detected OpenGL error '" << error<<"'";
else osg::notify(WARN)<<"Warning: detected OpenGL error number 0x" << std::hex << errorNo << std::dec; else osg::notify(WARN)<<"Warning: detected OpenGL error number 0x" << std::hex << errorNo << std::dec;
#else #else
switch(errorNo)
{
case(GL_INVALID_ENUM):
osg::notify(WARN)<<"Warning: detected OpenGL error GL_INVALID_ENUM";
break;
case(GL_INVALID_VALUE):
osg::notify(WARN)<<"Warning: detected OpenGL error GL_INVALID_VALUE";
break;
case(GL_INVALID_OPERATION):
osg::notify(WARN)<<"Warning: detected OpenGL error GL_INVALID_OPERATION";
break;
case(GL_OUT_OF_MEMORY):
osg::notify(WARN)<<"Warning: detected OpenGL error GL_OUT_OF_MEMORY";
break;
default:
osg::notify(WARN)<<"Warning: detected OpenGL error number 0x" << std::hex << errorNo << std::dec; osg::notify(WARN)<<"Warning: detected OpenGL error number 0x" << std::hex << errorNo << std::dec;
break;
}
#endif #endif
if (str) osg::notify(WARN)<<" at "<<str<< std::endl; if (str) osg::notify(WARN)<<" at "<<str<< std::endl;
else osg::notify(WARN)<<" in osg::State."<< std::endl; else osg::notify(WARN)<<" in osg::State."<< std::endl;
@ -1103,13 +1120,30 @@ bool State::checkGLErrors(StateAttribute::GLMode mode) const
GLenum errorNo = glGetError(); GLenum errorNo = glGetError();
if (errorNo!=GL_NO_ERROR) if (errorNo!=GL_NO_ERROR)
{ {
#ifdef OSG_GLU_AVAILABLE #ifdef OSG_GLU_AVAILABLE
const char* error = (char*)gluErrorString(errorNo); const char* error = (char*)gluErrorString(errorNo);
if (error) osg::notify(WARN)<<"Warning: detected OpenGL error '"<< error <<"' after applying GLMode 0x"<<hex<<mode<<dec<< std::endl; if (error) osg::notify(WARN)<<"Warning: detected OpenGL error '"<< error <<"' after applying GLMode 0x"<<hex<<mode<<dec<< std::endl;
else osg::notify(WARN)<<"Warning: detected OpenGL error number 0x"<< std::hex << errorNo <<" after applying GLMode 0x"<<hex<<mode<<dec<< std::endl; else osg::notify(WARN)<<"Warning: detected OpenGL error number 0x"<< std::hex << errorNo <<" after applying GLMode 0x"<<hex<<mode<<dec<< std::endl;
#else #else
switch(errorNo)
{
case(GL_INVALID_ENUM):
osg::notify(WARN)<<"Warning: detected OpenGL error GL_INVALID_ENUM after applying GLMode 0x"<<hex<<mode<<dec<< std::endl;
break;
case(GL_INVALID_VALUE):
osg::notify(WARN)<<"Warning: detected OpenGL error GL_INVALID_VALUE after applying GLMode 0x"<<hex<<mode<<dec<< std::endl;
break;
case(GL_INVALID_OPERATION):
osg::notify(WARN)<<"Warning: detected OpenGL error GL_INVALID_OPERATION after applying GLMode 0x"<<hex<<mode<<dec<< std::endl;
break;
case(GL_OUT_OF_MEMORY):
osg::notify(WARN)<<"Warning: detected OpenGL error GL_OUT_OF_MEMORY after applying GLMode 0x"<<hex<<mode<<dec<< std::endl;
break;
default:
osg::notify(WARN)<<"Warning: detected OpenGL error number 0x"<< std::hex << errorNo <<" after applying GLMode 0x"<<hex<<mode<<dec<< std::endl; osg::notify(WARN)<<"Warning: detected OpenGL error number 0x"<< std::hex << errorNo <<" after applying GLMode 0x"<<hex<<mode<<dec<< std::endl;
#endif break;
}
#endif
return true; return true;
} }
return false; return false;
@ -1120,13 +1154,30 @@ bool State::checkGLErrors(const StateAttribute* attribute) const
GLenum errorNo = glGetError(); GLenum errorNo = glGetError();
if (errorNo!=GL_NO_ERROR) if (errorNo!=GL_NO_ERROR)
{ {
#ifdef OSG_GLU_AVAILABLE #ifdef OSG_GLU_AVAILABLE
const char* error = (char*)gluErrorString(errorNo); const char* error = (char*)gluErrorString(errorNo);
if (error) osg::notify(WARN)<<"Warning: detected OpenGL error '"<< error <<"' after applying attribute "<<attribute->className()<<" "<<attribute<< std::endl; if (error) osg::notify(WARN)<<"Warning: detected OpenGL error '"<< error <<"' after applying attribute "<<attribute->className()<<" "<<attribute<< std::endl;
else osg::notify(WARN)<<"Warning: detected OpenGL error number 0x"<< std::hex << errorNo <<" after applying attribute "<<attribute->className()<<" "<<attribute<< std::dec << std::endl; else osg::notify(WARN)<<"Warning: detected OpenGL error number 0x"<< std::hex << errorNo <<" after applying attribute "<<attribute->className()<<" "<<attribute<< std::dec << std::endl;
#else #else
switch(errorNo)
{
case(GL_INVALID_ENUM):
osg::notify(WARN)<<"Warning: detected OpenGL error GL_INVALID_ENUM after applying attribute "<<attribute->className()<<" "<<attribute<< std::dec << std::endl;
break;
case(GL_INVALID_VALUE):
osg::notify(WARN)<<"Warning: detected OpenGL error GL_INVALID_VALUE after applying attribute "<<attribute->className()<<" "<<attribute<< std::dec << std::endl;
break;
case(GL_INVALID_OPERATION):
osg::notify(WARN)<<"Warning: detected OpenGL error GL_INVALID_OPERATION after applying attribute "<<attribute->className()<<" "<<attribute<< std::dec << std::endl;
break;
case(GL_OUT_OF_MEMORY):
osg::notify(WARN)<<"Warning: detected OpenGL error GL_OUT_OF_MEMORY after applying attribute "<<attribute->className()<<" "<<attribute<< std::dec << std::endl;
break;
default:
osg::notify(WARN)<<"Warning: detected OpenGL error number 0x"<< std::hex << errorNo <<" after applying attribute "<<attribute->className()<<" "<<attribute<< std::dec << std::endl; osg::notify(WARN)<<"Warning: detected OpenGL error number 0x"<< std::hex << errorNo <<" after applying attribute "<<attribute->className()<<" "<<attribute<< std::dec << std::endl;
#endif break;
}
#endif
return true; return true;
} }

View File

@ -886,16 +886,8 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
if(state.getCheckForGLErrors()!=osg::State::NEVER_CHECK_GL_ERRORS) if(state.getCheckForGLErrors()!=osg::State::NEVER_CHECK_GL_ERRORS)
{ {
GLenum errorNo = glGetError(); if (state.checkGLErrors("after RenderBin::draw(..)"))
if (errorNo!=GL_NO_ERROR)
{ {
#ifdef OSG_GLU_AVAILABLE
const char* error = (char*)gluErrorString(errorNo);
if (error) osg::notify(osg::NOTICE)<<"Warning: detected OpenGL error '"<<error<<"' after RenderBin::draw(,)"<<std::endl;
else osg::notify(osg::NOTICE)<<"Warning: detected OpenGL errorNo= 0x"<<std::hex<<errorNo<<" after RenderBin::draw(,)"<<std::dec<<std::endl;
#else
osg::notify(osg::NOTICE)<<"Warning: detected OpenGL errorNo= 0x"<<std::hex<<errorNo<<" after RenderBin::draw(,)"<<std::dec<<std::endl;
#endif
if ( fbo_ext ) if ( fbo_ext )
{ {
GLenum fbstatus = fbo_ext->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); GLenum fbstatus = fbo_ext->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);