双击 cmake.msi,默认安装即可
找到glfw所解压的路径
此处为:
D:\source\glfw-3.3.8
先在命令行输入:
cd D:\source\glfw-3.3.8
再输入:
D:
即可切换到glfw的路径。
再输入:cmake .
完成后GLFW目录如图所示
用 VS2019 打开 GLFW.sln
点击重新生成解决方案,等待执行结束(30秒左右)。
1、
找到 glew32.dll 复制到 DLL 文件夹
2、
放入 Include 文件夹
3、
放入 Lib 文件夹
1、

2、

3、

将上面生成的三个文件夹 Include DLL Lib 放入与.sln同级的目录下。
右击项目名,选择属性
进行以下配置:
1、

2、

3、

4、

#include
#include
#include
const int WIDTH = 1600;
const int HEIGHT = 1200;
int main()
{
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "OpenGL", NULL, NULL);
if (window == NULL)
{
std::cout << "Failed to create GLFW window!" << std::endl;
glfwTerminate();
return - 1;
}
return 0;
}