c++openglmingwglfwglad

GLAD link is not providing needed functions


TLDR: The GLAD header file won't let me use the openGL Commands and I don't know exactly why.

Here's a breakdown:

I have tried re-installing GLAD, but that didn't do anything. I haven't tried re-installing GLFW, but I don't think that's the problem.

Correct any misconceptions I have or errors I am making.


Solution

  • You need to include glad.c in your compile command as follows: (you had a -L before it which tells gcc to treat glad.c as a directory for libraries)

    g++ GraphicsTest.cpp glad.c -g glfw3.dll
    

    , and instead of gladLoadGL, you should use the GLFW loader:

        if (!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress)) {
            std::cout << "Failed to initialize OpenGL context" << std::endl;
            return -1;
        }
    

    Finally, you should invest a tiny bit of time into a decent build system because compiling every file every time will get real slow real fast. Here is the absolute minimal Makefile to get you started:

    graphicstest: graphicstest.o glad.o
      g++ -g -o $@ $^ glfw3.dll