Adding a minimal working example for GLX with X11
Hello,
please, could you add a simple C++ example program of GLAD working with GLX and a X11 lib window in the example folder ?

I have much trouble trying to do just that, and no luck searching.
As soon as I include glad_glx.h instead of the GL/gl.h and glx.h classic headers in a X11 project, it immediately crashes (segmentation fault), because glad re-#defines all the glX functions (eg. glXQueryVersion), and they become uninitialized function pointers when including glad_glx.h.

Calling gladLoadGLX(<my_display>, <my_screen>) doesn't help...
But glXQueryVersion is one of the very first things my program does, so I need it working. What should I do ? I'm a bit lost.

I tried to isolate the issue in a minimal example but came across other problems.

I started from the minimal OpenGL + X11 program found [here](https://www.opengl.org/discussion_boards/showthread.php/165856-Minimal-GLX-OpenGL3-0-example?p=1178905&viewfull=1#post1178905), which works well.

But trying to add Glad to the mix, it doesn't compile anymore (more details below).
I generated glad GLX 1.4 debug files with the web interface. But trying to compile with them throws me compile errors like `undefined reference to 'glad_debug_glClearColor'` and `undefined reference to 'glad_debug_glClear'`.

What can I do from here ? If I try to add, for instance, an OpenGL 4.5 Core glad.c to the project, I now have errors because of `multiple definitions of glad_set_pre_callback`, because both the glad.c and glad_glx.c will define it...

Can you help me understand how to use glad in this situation ?
If I can get it working I'd even be glad (ha!) to make a PR to add it to the example/ folder myself !


---------------------------------
To quickly reproduce:
 my failing compile command is like `g++ glad/src/glad_glx.c glad/glad.c gl3.cpp -o gl3 -lX11 -lGL -ldl -I glad/include -I.`

and here's the full copy of the working minimal example of opengl.org (save as gl3.cpp and compile with "g++ gl3.cpp -o gl3 -lX11 -lGL"):
```
#include <GL/glx.h>
#include <GL/gl.h>
#include <unistd.h>
#include <iostream>
 
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
 
#define GLX_CONTEXT_MAJOR_VERSION_ARB       0x2091
#define GLX_CONTEXT_MINOR_VERSION_ARB       0x2092
typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
 
int main (int argc, char ** argv)
{
    Display *display = XOpenDisplay(0);
 
    glXCreateContextAttribsARBProc glXCreateContextAttribsARB = NULL;
 
    const char *extensions = glXQueryExtensionsString(display, DefaultScreen(display));
    std::cout << extensions << std::endl;
 
    static int visual_attribs[] =
    {
        GLX_RENDER_TYPE, GLX_RGBA_BIT,
        GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
        GLX_DOUBLEBUFFER, true,
        GLX_RED_SIZE, 1,
        GLX_GREEN_SIZE, 1,
        GLX_BLUE_SIZE, 1,
        None
     };
 
    std::cout << "Getting framebuffer config" << std::endl;
    int fbcount;
    GLXFBConfig *fbc = glXChooseFBConfig(display, DefaultScreen(display), visual_attribs, &amp;fbcount);
    if (!fbc)
    {
        std::cout << "Failed to retrieve a framebuffer config" << std::endl;
        return 1;
    }
 
    std::cout << "Getting XVisualInfo" << std::endl;
    XVisualInfo *vi = glXGetVisualFromFBConfig(display, fbc[0]);
 
    XSetWindowAttributes swa;
    std::cout << "Creating colormap" << std::endl;
    swa.colormap = XCreateColormap(display, RootWindow(display, vi->screen), vi->visual, AllocNone);
    swa.border_pixel = 0;
    swa.event_mask = StructureNotifyMask;
 
    std::cout << "Creating window" << std::endl;
    Window win = XCreateWindow(display, RootWindow(display, vi->screen), 0, 0, 100, 100, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel|CWColormap|CWEventMask, &amp;swa);
    if (!win)
    {
        std::cout << "Failed to create window." << std::endl;
        return 1;
    }
 
    std::cout << "Mapping window" << std::endl;
    XMapWindow(display, win);
 
    // Create an oldstyle context first, to get the correct function pointer for glXCreateContextAttribsARB
    GLXContext ctx_old = glXCreateContext(display, vi, 0, GL_TRUE);
    glXCreateContextAttribsARB =  (glXCreateContextAttribsARBProc)glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB");
    glXMakeCurrent(display, 0, 0);
    glXDestroyContext(display, ctx_old);
 
    if (glXCreateContextAttribsARB == NULL)
    {
        std::cout << "glXCreateContextAttribsARB entry point not found. Aborting." << std::endl;
        return false;
    }
 
    static int context_attribs[] =
    {
        GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
        GLX_CONTEXT_MINOR_VERSION_ARB, 0,
        None
    };
 
    std::cout << "Creating context" << std::endl;
    GLXContext ctx = glXCreateContextAttribsARB(display, fbc[0], NULL, true, context_attribs);
    if (!ctx)
    {
        std::cout << "Failed to create GL3 context." << std::endl;
        return 1;
    }
 
    std::cout << "Making context current" << std::endl;
    glXMakeCurrent(display, win, ctx);
 
        glClearColor (0, 0.5, 1, 1);
        glClear (GL_COLOR_BUFFER_BIT);
        glXSwapBuffers (display, win);
 
        sleep(1);
 
        glClearColor (1, 0.5, 0, 1);
        glClear (GL_COLOR_BUFFER_BIT);
        glXSwapBuffers (display, win);
 
        sleep(1);
 
    ctx = glXGetCurrentContext();
    glXMakeCurrent(display, 0, 0);
    glXDestroyContext(display, ctx);
}
```
