Configuration of OpenGL development environment under Windows environment, win10 + vs2019 + glfw + glad

GLFW library configuration 1. The first step, look up a lot of tutorials are selected directly on the web site to download GLFW source code, and then use CMake program compiled, but I don’t know why I always make mistakes during compilation, so finally give up this way, choose directly on the website to download the 64 – bit Windows precompiled binary 】, the diagram below

After you download it, copy the included file and the corresponding version of the library (because mine is vs2019) lib-vc2019 and place it in a fixed location (create a new folder to put both of them in it), such as my location under the path C: Program Files\OpenGL
2. The second step is the configuration of GLAD. Go to the GLAD online service page and select the corresponding options after entering it, as shown in the picture

You will get a Glad. Zip file. Download it and unzip it. Copy the two Files Glad and Khr in the include folder and place them in the C:\Program Files\OpenGL\ Include folder in the path of our first step

Copy the SRC folder to the path C: Program Files\OpenGL, as shown in the figure

3. Next, open VS2019 and create a new blank item. Click “Other Window” in “View” in the menu bar to find “Property Manager”, as shown in the figure below

Double click the Debug | x64 “folder” Microsoft. Cpp. X64. User], click on the vc + + directories add directory contains 】 【 in 】 directory, add, the following figure, OpenCV everyone here don’t tube, just add the OpenGL.

Configuration engineering library catalog, is also a double click the Debug | x64 】 in the folder. Microsoft. Cpp x64. User 】 【, click on the vc + + library directory 】 【 in 】 to add, as shown, also don’t tube of OpenCV.

Link library configuration, is also a double click the Debug | x64 】 in the folder. Microsoft. Cpp x64. User 】 【, click on the “input” of the “connector”, is added in the “additional dependencies” library Files and library Files in the C: \ Program Files \ OpenGL \ lib – vc2019, copy and paste the name to the “additional dependencies”, as shown in figure

At this point, our OpenGL environment is configured, but each time we create a new project, we need to add the glad.c file under the path C: Program Files\OpenGL\ SRC to the source of our project, and that’s it.
4. Test
The code is as follows:

#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <iostream>
using namespace std;

void framebuffer_size_callback(GLFWwindow* window, int width, int height);

int main() {

	GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL);
	if (window == NULL) {
		cout << "Failed to create GLFW window" << endl;
		return -1;

	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)) {

	return 0;

void framebuffer_size_callback(GLFWwindow* window, int width, int height) {
	glViewport(0, 0, width, height);

The results show that the configuration was successful.


Read More: