Which package to install to get header file glad.h?

I am trying to compile this example https://learnopengl.com/Getting-started/Hello-Window:

#include <glad/glad.h>
#include <GLFW/glfw3.h>
// ...

I have installed libglfw3-dev but I am still missing the glad.h header file. A search on packages.ubuntu.com gave no results. There is a github page for glad but it does not provide glad.h as far as I can see.


Solution 1:

Thanks to @dc37 for the comment on the webservice! Here is what I did: Go to the webservice and download the required files:


enter image description here


Check the "local files" option and click on the "Generate" button in the lower right corner,


enter image description here


download the glad.zip file to the current directory and extract it.

Create a test program test.cpp:

#include <iostream>
#include "glad.h"
#include <GLFW/glfw3.h>  
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
    glViewport(0, 0, width, height);
}

int main() {
    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    //glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL);
    if (window == NULL) {
            std::cout << "Failed to create GLFW window" << std::endl;
            glfwTerminate();
            return -1;
    }
    glfwMakeContextCurrent(window);
    if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
        std::cout << "Failed to initialize GLAD" << std::endl;
        return -1;
    }
    glViewport(0, 0, 800, 600);
    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
    while(!glfwWindowShouldClose(window)) {
        glfwSwapBuffers(window);
        glfwPollEvents();    
    }
    glfwTerminate();
    return 0;
}

Compile it (remember to install libglfw3-dev first):

g++ -c glad.c 
g++ test.cpp -o my_test glad.o -lglfw -ldl

Run it:

$ ./my_test

(It shows an empty window on the screen)