Questions in category: GLFW (GLFW)
软件 >> C++ >> GLFW

1. [GLFW] 教程1

Posted by haifeng on 2021-04-29 10:33:20 last update 2021-04-29 10:51:14 | Answers (0) | 收藏


第一个 GLFW 程序

目标: 对 GLFW 官网上的 example code 进行编译.

操作系统(OS): Windows 10

集成开发环境(IDE):Visual Studio 2019

准备工作

1. 首先到 GLFW 官网下载 GLFW 的相关文件 (Download | GLFW). 我们以 Windows 为例, 下载

Windows pre-compiled binaries

解压缩到 D:\Lib 目录下. 例如: D:\Lib\glfw-3.3.4.bin.WIN64

结构如下:

D:\LIB\GLFW-3.3.4.BIN.WIN64
├─docs
│  └─html
│      └─search
├─include                   // 包含目录
│  ├─glad
│  ├─GLFW
│  ├─mingw
│  └─vs2008
├─lib-mingw-w64
├─lib-static-ucrt
├─lib-vc2012
├─lib-vc2013
├─lib-vc2015
├─lib-vc2017
└─lib-vc2019              // 将其作为库目录


2.  保存 example code  Documentation | GLFW  到文件 main.cpp

具体的, 打开 Visual Studio 2019, 新建空项目. 然后在源文件中添加新的源文件 main.cpp, 将 example code 拷贝到 main.cpp 中. 保存.

 

3. 配置属性

【配置属性】-->【VC++ 目录】-->[常规]-->[包含目录] : 添加 D:\Lib\glfw-3.3.4.bin.WIN64\include

【配置属性】-->【VC++ 目录】-->[常规]-->[库目录] : 添加 D:\Lib\glfw-3.3.4.bin.WIN64\lib-vc2019

【配置属性】-->【链接器】-->【输入】-->[附加依赖项]:添加 glfw3.lib 和 OpenGL32.lib

 

4. 编译

 

Enjoy.