Added support for controlling the frequency of checking for OpenGL errors

via:

        enum CheckForGLErrors
        {
            /** NEVER_CHECK_GL_ERRORS hints that OpenGL need not be checked for, this
                is the fastest option since checking for errors does incurr a small overhead.*/
            NEVER_CHECK_GL_ERRORS,
            /** ONCE_PER_FRAME means that OpenGl errors will be checked for once per
                frame, the overhead is still small, but at least OpenGL errors that are occurring
                will be caught, the reporting isn't fine grained enough for debugging purposes.*/
            ONCE_PER_FRAME,
            /** ONCE_PER_ATTRIBUTE means that OpenGL errors will be checked for after
                every attribute is applied, allow errors to be directly associated with
                particular operations which makes debugging much easier.*/
            ONCE_PER_ATTRIBUTE
        };

        /** Set whether and how often OpenGL errors should be checked for.*/
        void setCheckForGLErrors(CheckForGLErrors check) { _checkGLErrors = check; }

        /** Get whether and how often OpenGL errors should be checked for.*/
        CheckForGLErrors getCheckForGLErrors() const { return _checkGLErrors; }
This commit is contained in:
Robert Osfield
2005-04-29 20:56:20 +00:00
parent 0ff98ceb59
commit 7117ff4bd3
3 changed files with 39 additions and 16 deletions

View File

@@ -938,12 +938,17 @@ void SceneView::draw()
// re apply the defalt OGL state.
_state->popAllStateSets();
GLenum errorNo = glGetError();
if (errorNo!=GL_NO_ERROR)
if (_state->getCheckForGLErrors()!=osg::State::NEVER_CHECK_GL_ERRORS)
{
osg::notify(WARN)<<"Warning: detected OpenGL error '"<<gluErrorString(errorNo)<<"'"<< std::endl;
// go into debug mode of OGL errors.
_state->setReportGLErrors(true);
GLenum errorNo = glGetError();
if (errorNo!=GL_NO_ERROR)
{
osg::notify(WARN)<<"Warning: detected OpenGL error '"<<gluErrorString(errorNo)<<"'"<< std::endl;
// go into debug mode of OGL error in a fine grained way to help
// track down OpenGL errors.
_state->setCheckForGLErrors(osg::State::ONCE_PER_ATTRIBUTE);
}
}
}