2

I wrote a minimal OpenGL application and linked the console to the project. OpenGL outputs its Version and things like that to the console.

The small OpenGL framework that I am writing will be used by an aplpication that features its own logging so i want to redirect all logging to there.

So far I tried googling the problem but I can not find all the information I need. There are debugging tools, but those are stand alone. I found logging options but it is not clear to me if this is meant to catch all messages or just some.

void glDebugMessageCallback​(DEBUGPROC callback​, void* userParam​);

Will registering with this function catch all messages or will I miss some of them. If so, how do I log everything?

Johannes
  • 6,490
  • 10
  • 59
  • 108

3 Answers3

2

OpenGL by itself will not produce any debugging output whatsoever. glDebugMessageCallback is a relatively new feature with the sole intention to offer a conduit through which debugging messages can be sent. But without that OpenGL will not produce any debugging output.

Colonel Thirty Two
  • 23,953
  • 8
  • 45
  • 85
datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • I noticed that some of the output came from an intermediate layer. The OpenGL SuperBible, 6th Edition source code also creates its own output. 'application::run' outputs if compliled with '_DEBUG' defined. – Johannes May 06 '15 at 10:29
1

glDebugMessageCallback is working fine on my side. The following code might be of your interest. Note that glDebugMessageCallback requires OpenGL > 4.3.

glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback([](
    GLenum source, GLenum type, GLuint id,
    GLenum severity, GLsizei length, const GLchar *message, const void *userParam) {

#pragma GCC diagnostic ignored "-Wswitch"
  const char *_source = "Unknown";
  switch (source) {
    case GL_DEBUG_SOURCE_WINDOW_SYSTEM:   _source = "WinSys";         break;
    case GL_DEBUG_SOURCE_APPLICATION:     _source = "App";            break;
    case GL_DEBUG_SOURCE_API:             _source = "OpenGL";         break;
    case GL_DEBUG_SOURCE_SHADER_COMPILER: _source = "ShaderCompiler"; break;
    case GL_DEBUG_SOURCE_THIRD_PARTY:     _source = "3rdParty";       break;
    case GL_DEBUG_SOURCE_OTHER:           _source = "Other";          break;
  }
  const char *_type = "Unknown";
  switch (type) {
    case GL_DEBUG_TYPE_ERROR:               _type = "Error";       break;
    case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: _type = "Deprecated";  break;
    case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:  _type = "Undefined";   break;
    case GL_DEBUG_TYPE_PORTABILITY:         _type = "Portability"; break;
    case GL_DEBUG_TYPE_PERFORMANCE:         _type = "Performance"; break;
    case GL_DEBUG_TYPE_MARKER:              _type = "Marker";      break;
    case GL_DEBUG_TYPE_PUSH_GROUP:          _type = "PushGrp";     break;
    case GL_DEBUG_TYPE_POP_GROUP:           _type = "PopGrp";      break;
    case GL_DEBUG_TYPE_OTHER:               _type = "Other";       break;
  }
  const char *_severity = "Unknown";
  switch (severity) {
    case GL_DEBUG_SEVERITY_HIGH:         _severity = "High";   break;
    case GL_DEBUG_SEVERITY_MEDIUM:       _severity = "Med";    break;
    case GL_DEBUG_SEVERITY_LOW:          _severity = "Low";    break;
    case GL_DEBUG_SEVERITY_NOTIFICATION: _severity = "Notify"; break;
  }
#pragma GCC diagnostic warning "-Wswitch"
  cerr << _source << "." << _type << "[" << _severity << "](" <<
    id << "): " << message << endl;
}, nullptr);
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0, 
                     GL_DEBUG_SEVERITY_NOTIFICATION, -1, "Start debugging");
ken
  • 333
  • 2
  • 11
1

The question seems to be - How to redirect console logs generated by an OpenGL framework, to another layer. OpenGL itself does not generate any logs, and even the log callbacks are just that - Callbacks to another function registered by the application, they do not "log" anything to the console unless the callback does it.

To redirect logs to another file or another layer, you can refer to shell redirection techniques like How can I redirect console output to file?.

Community
  • 1
  • 1
Prabindh
  • 3,356
  • 2
  • 23
  • 25
  • Actually I was just being an idiot :). The messages did not come from OpenGL but from the SuperBible Source. – Johannes Jan 28 '16 at 11:07