Glad function description / documentation

456 Views Asked by At

I am learning how to build and run OpenGL with C. And i am using Glad as a function loader. Keeping it simple, i am compiling and linking manually. Everything works.

(Using Visual Studio Code as an IDE)

It is helpful to show what a function does. And this normally shows up when hovering over it. (Documentation)

But when i hover over the "glClear(GL_COLOR_BUFFER_BIT)" as an example it does not show the OpenGL definition of the function.

Instead it shows:

#define glClear glad_glClear

Expands to: glad_glClear

Is there a way to show the OpenGL documentation instead?

My only dependencies are Glad and GLFW.

2

There are 2 best solutions below

0
Nicol Bolas On BEST ANSWER

GLAD-generated headers do not contain any information that a tool like a VS Code plugin can use to track down documentation. They certainly do not contain the documentation itself.

0
Dave On

Glad hides its functions behind macros which is tricky. Some IDEs will complete the macros, some will not. A brute force solution could be to wrap each Glad function with documentation. Similar to how other libraries like LWJGL wrap OpenGL. Here is an example

#ifndef GL_DOC_H
#define GL_DOC_H

#include <glad/glad.h>

#ifdef __cplusplus
extern "C" {
#endif

#undef glClear

/**
 * glClear — clear buffers to preset values
 *
 * @param mask Bitwise OR of masks that indicate the buffers to be cleared.
 * The three masks are GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, and
 * GL_STENCIL_BUFFER_BIT.
 */
static inline void glClear(GLbitfield mask) { 
  glad_glClear(mask);
}

#ifdef __cplusplus
}
#endif

#endif // GL_DOC_H