Re: [osg-users] Creating an OpenGL debug context

57 views
Skip to first unread message

Voerman, L.

unread,
Mar 25, 2021, 9:11:12 AM3/25/21
to OpenSceneGraph Users
Not exactly what you're asking for, but this is extracted from my code:
Laurens.

#ifdef OPENGL_DEBUG
void APIENTRY DebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * message, const void* userParam) {
    printf("0x % X: %s\n", id, message);
}
#endif


class EnableGLDebugCallback : public osg::GraphicsOperation
{
public:
EnableGLDebugCallback() :
GraphicsOperation("EnableGLDebug", true),
_dirty(true) { }
virtual void operator () (osg::GraphicsContext* context) {
if (_dirty) {
#ifdef OPENGL_DEBUG
if (osg::isGLExtensionSupported(contextID, "GL_KHR_debug")) {
//PFNGLDEBUGMESSAGECALLBACKPROC
PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC)wglGetProcAddress("glDebugMessageCallback");
PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC)wglGetProcAddress("glDebugMessageControl");
glDebugMessageCallback(DebugCallback, NULL);
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, 0, GL_TRUE);
glEnable(GL_DEBUG_OUTPUT);
//glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
}
#endif
_dirty = false;
}
}
protected:
bool                    _dirty;
};
};

in main thread:
        osg::GraphicsContext *gc = _viewer->getCamera()->getGraphicsContext();
        if (gc) {
            gc->add(new EnableGLDebugCallback());
            OSGRC_DEBUG("EnableGLDebugCallback installed" << std::endl);
        }

On Thu, Mar 25, 2021 at 11:41 AM Werner Modenbach <Werner.M...@modenbach-ac.de> wrote:
Hi all,

does anybody know how to create an opengl debug context via flags in the traits?

Thanks

- Werner -
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Reply all
Reply to author
Forward
0 new messages