[osg-users] Creating an OpenGL debug context
Voerman, L.
l.voerman at rug.nl
Thu Mar 25 06:10:53 PDT 2021
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.Modenbach at 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-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20210325/9dc08dcd/attachment.html>
More information about the osg-users
mailing list