Skip to main content
fixed typos & markdown
Source Link
Pikalek
  • 13.4k
  • 5
  • 49
  • 54

This is less a specific answer to the question, but a general hint on how to set up an OpenGL context because iI feel it will answer the question automatically. The same procedure is used for instance by 'learnopengl.com' and possibly others I don't know. My system is a Debian 10, but it should work on Windows as well.

1.) - Headers to be included:

2.) - Initialize glfw, load opengl functions:

Now two things are still mssingmissing, the glfw_debug_callbackglfw_debug_callback and the glDebugCallbackglDebugCallback. I leave the function body out because mines aremine is pretty verbose:

void APIENTRY glDebugOutput( GLenum source, GLenum type, GLuint id, GLenum severity,
    GLsizei length, const GLchar *message, const void *userParam ) {
// Ignore non-significant error/warning codes
// pseudcode: if( id == 131169 || id = whateverelse ) return;
/* stitch togehter and format a msg from source: 
   GL_DEBUG_SOURCE_API, GL_DEBUG_SOURCE_WINDOW_SYSTEM,
   GL_DEBUG_SOURCE_SHADER_COMPILER, GL_DEBUG_SOURCE_THIRD_PARTY,
   GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_SOURCE_OTHER
   type:
   GL_DEBUG_TYPE_ERROR, GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR;
   GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR, GL_DEBUG_TYPE_PORTABILITY,
   GL_DEBUG_TYPE_PERFORMANCE, GL_DEBUG_TYPE_MARKER,
   GL_DEBUG_TYPE_PUSH_GROUP, GL_DEBUG_TYPE_POP_GROUP,
   GL_DEBUG_TYPE_OTHER
   and severity:
   GL_DEBUG_SEVERITY_HIGH, GL_DEBUG_SEVERITY_MEDIUM,
   GL_DEBUG_SEVERITY_LOW, GL_DEBUG_SEVERITY_NOTIFICATION */
   // add the message text and eventually add userdata
   // log/output
}

}

With this one receives meaningfullmeaningful messages on error conditions. Checking glErrorglError is not necessary any more and parametrizedparameterized one can run with a debug context and without, saving a bit of performance.

This is less a specific answer to the question, but a general hint on how to set up an OpenGL context because i feel it will answer the question automatically. The same procedure is used for instance by 'learnopengl.com' and possibly others I don't know. My system is a Debian 10, but it should work on Windows as well.

1.) Headers to be included:

2.) Initialize glfw, load opengl functions:

Now two things are still mssing, the glfw_debug_callback and the glDebugCallback. I leave the function body out because mines are pretty verbose:

void APIENTRY glDebugOutput( GLenum source, GLenum type, GLuint id, GLenum severity,
    GLsizei length, const GLchar *message, const void *userParam ) {
// Ignore non-significant error/warning codes
// pseudcode: if( id == 131169 || id = whateverelse ) return;
/* stitch togehter and format a msg from source: 
   GL_DEBUG_SOURCE_API, GL_DEBUG_SOURCE_WINDOW_SYSTEM,
   GL_DEBUG_SOURCE_SHADER_COMPILER, GL_DEBUG_SOURCE_THIRD_PARTY,
   GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_SOURCE_OTHER
   type:
   GL_DEBUG_TYPE_ERROR, GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR;
   GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR, GL_DEBUG_TYPE_PORTABILITY,
   GL_DEBUG_TYPE_PERFORMANCE, GL_DEBUG_TYPE_MARKER,
   GL_DEBUG_TYPE_PUSH_GROUP, GL_DEBUG_TYPE_POP_GROUP,
   GL_DEBUG_TYPE_OTHER
   and severity:
   GL_DEBUG_SEVERITY_HIGH, GL_DEBUG_SEVERITY_MEDIUM,
   GL_DEBUG_SEVERITY_LOW, GL_DEBUG_SEVERITY_NOTIFICATION */
   // add the message text and eventually add userdata
   // log/output

}

With this one receives meaningfull messages on error conditions. Checking glError is not necessary any more and parametrized one can run with a debug context and without, saving a bit of performance.

This is less a specific answer to the question, but a general hint on how to set up an OpenGL context because I feel it will answer the question automatically. The same procedure is used for instance by 'learnopengl.com' and possibly others I don't know. My system is a Debian 10, but it should work on Windows as well.

1 - Headers to be included:

2 - Initialize glfw, load opengl functions:

Now two things are still missing, the glfw_debug_callback and the glDebugCallback. I leave the function body out because mine is pretty verbose:

void APIENTRY glDebugOutput( GLenum source, GLenum type, GLuint id, GLenum severity,
    GLsizei length, const GLchar *message, const void *userParam ) {
// Ignore non-significant error/warning codes
// pseudcode: if( id == 131169 || id = whateverelse ) return;
/* stitch togehter and format a msg from source: 
   GL_DEBUG_SOURCE_API, GL_DEBUG_SOURCE_WINDOW_SYSTEM,
   GL_DEBUG_SOURCE_SHADER_COMPILER, GL_DEBUG_SOURCE_THIRD_PARTY,
   GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_SOURCE_OTHER
   type:
   GL_DEBUG_TYPE_ERROR, GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR;
   GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR, GL_DEBUG_TYPE_PORTABILITY,
   GL_DEBUG_TYPE_PERFORMANCE, GL_DEBUG_TYPE_MARKER,
   GL_DEBUG_TYPE_PUSH_GROUP, GL_DEBUG_TYPE_POP_GROUP,
   GL_DEBUG_TYPE_OTHER
   and severity:
   GL_DEBUG_SEVERITY_HIGH, GL_DEBUG_SEVERITY_MEDIUM,
   GL_DEBUG_SEVERITY_LOW, GL_DEBUG_SEVERITY_NOTIFICATION */
   // add the message text and eventually add userdata
   // log/output
}

With this one receives meaningful messages on error conditions. Checking glError is not necessary any more and parameterized one can run with a debug context and without, saving a bit of performance.

deleted 33 characters in body
Source Link
user144188
user144188
glfwSetErrorCallback( glfw_error_callback );
if( GL_TRUE != glfwInit() ) {
    // didn't work, can't carry on
}
glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 4 );
glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 5 );
if( gl_window.debug_enabled )
    glfwWindowHint( GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE );
glfwWindowHint( GLFW_CLIENT_API, GLFW_OPENGL_API );
glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
void APIENTRY glDebugOutput( GLenum source, GLenum type, GLuint id, GLenum severity,
    GLsizei length, const GLchar *message, const void *userParam ) {
// Ignore non-significant error/warning codes
// pseudcode: if( id == 131169 || id = whateverelse ) return;
/* stitch togehter and format a msg from source: 
   GL_DEBUG_SOURCE_API, GL_DEBUG_SOURCE_WINDOW_SYSTEM,
   GL_DEBUG_SOURCE_SHADER_COMPILER, GL_DEBUG_SOURCE_THIRD_PARTY,
   GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_SOURCE_OTHER
   type:
   GL_DEBUG_TYPE_ERROR, GL_DEBUG_TYPE_DEPRECATED_BEHAVIORbreak;GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR;
   GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR, GL_DEBUG_TYPE_PORTABILITY,
   GL_DEBUG_TYPE_PERFORMANCE, GL_DEBUG_TYPE_MARKER,
   GL_DEBUG_TYPE_PUSH_GROUP, GL_DEBUG_TYPE_POP_GROUP,
   GL_DEBUG_TYPE_OTHER
   and severity:
   GL_DEBUG_SEVERITY_HIGH, GL_DEBUG_SEVERITY_MEDIUM,
   GL_DEBUG_SEVERITY_LOW, GL_DEBUG_SEVERITY_NOTIFICATION */
   // add the message text and eventually add userdata
   // log/output
glfwSetErrorCallback( glfw_error_callback );
if( GL_TRUE != glfwInit() ) {
    // didn't work
}
glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 4 );
glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 5 );
if( gl_window.debug_enabled )
    glfwWindowHint( GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE );
glfwWindowHint( GLFW_CLIENT_API, GLFW_OPENGL_API );
glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
void APIENTRY glDebugOutput( GLenum source, GLenum type, GLuint id, GLenum severity,
    GLsizei length, const GLchar *message, const void *userParam ) {
// Ignore non-significant error/warning codes
// pseudcode: if( id == 131169 || id = whateverelse ) return;
/* stitch togehter and format a msg from source: 
   GL_DEBUG_SOURCE_API, GL_DEBUG_SOURCE_WINDOW_SYSTEM,
   GL_DEBUG_SOURCE_SHADER_COMPILER, GL_DEBUG_SOURCE_THIRD_PARTY,
   GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_SOURCE_OTHER
   type:
   GL_DEBUG_TYPE_ERROR, GL_DEBUG_TYPE_DEPRECATED_BEHAVIORbreak;
   GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR, GL_DEBUG_TYPE_PORTABILITY,
   GL_DEBUG_TYPE_PERFORMANCE, GL_DEBUG_TYPE_MARKER,
   GL_DEBUG_TYPE_PUSH_GROUP, GL_DEBUG_TYPE_POP_GROUP,
   GL_DEBUG_TYPE_OTHER
   and severity:
   GL_DEBUG_SEVERITY_HIGH, GL_DEBUG_SEVERITY_MEDIUM,
   GL_DEBUG_SEVERITY_LOW, GL_DEBUG_SEVERITY_NOTIFICATION */
   // add the message text and eventually add userdata
   // log/output
glfwSetErrorCallback( glfw_error_callback );
if( GL_TRUE != glfwInit() ) {
    // didn't work, can't carry on
}
glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 4 );
glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 5 );
glfwWindowHint( GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE );
glfwWindowHint( GLFW_CLIENT_API, GLFW_OPENGL_API );
glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
void APIENTRY glDebugOutput( GLenum source, GLenum type, GLuint id, GLenum severity,
    GLsizei length, const GLchar *message, const void *userParam ) {
// Ignore non-significant error/warning codes
// pseudcode: if( id == 131169 || id = whateverelse ) return;
/* stitch togehter and format a msg from source: 
   GL_DEBUG_SOURCE_API, GL_DEBUG_SOURCE_WINDOW_SYSTEM,
   GL_DEBUG_SOURCE_SHADER_COMPILER, GL_DEBUG_SOURCE_THIRD_PARTY,
   GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_SOURCE_OTHER
   type:
   GL_DEBUG_TYPE_ERROR, GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR;
   GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR, GL_DEBUG_TYPE_PORTABILITY,
   GL_DEBUG_TYPE_PERFORMANCE, GL_DEBUG_TYPE_MARKER,
   GL_DEBUG_TYPE_PUSH_GROUP, GL_DEBUG_TYPE_POP_GROUP,
   GL_DEBUG_TYPE_OTHER
   and severity:
   GL_DEBUG_SEVERITY_HIGH, GL_DEBUG_SEVERITY_MEDIUM,
   GL_DEBUG_SEVERITY_LOW, GL_DEBUG_SEVERITY_NOTIFICATION */
   // add the message text and eventually add userdata
   // log/output
deleted 6 characters in body
Source Link
user144188
user144188

With this one shoudl receivereceives meaningfull messages on error conditions. Checking glError is not necessary andany more and parametrized one can run with a debug context and without, saving a bit of performance.

With this one shoudl receive meaningfull messages on error conditions. Checking glError is not necessary and more and parametrized one can run with a debug context and without, saving a bit of performance.

With this one receives meaningfull messages on error conditions. Checking glError is not necessary any more and parametrized one can run with a debug context and without, saving a bit of performance.

minor corrections
Source Link
user144188
user144188
Loading
Source Link
user144188
user144188
Loading