vscode配置OpenGL开发环境
时间: 2023-11-11 09:00:56 浏览: 195
好的,以下是在 VS Code 中配置 OpenGL 开发环境的步骤:
1. 安装 MinGW-w64
在 MinGW-w64 的官网(https://sourceforge.net/projects/mingw-w64/)下载最新版本的安装程序,选择对应的系统位数和架构进行下载。安装时选择默认选项即可。
2. 安装 OpenGL 库
在 OpenGL 的官网(https://www.opengl.org/)下载最新版本的库文件,解压后将其中的头文件和库文件分别复制到 MinGW-w64 的安装目录下的 include 和 lib 文件夹中。
3. 配置 VS Code
在 VS Code 中打开项目文件夹,按下 Ctrl+Shift+P 打开命令面板,输入“C/C++: Edit Configurations”,选择“C/C++: g++.exe”并点击“Add Configuration”,然后将以下代码粘贴到打开的 launch.json 文件中:
```
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}
```
4. 编写代码
在 VS Code 中新建一个 C++ 文件,编写 OpenGL 代码并保存。
5. 编译运行
按下 F5 编译并运行代码,如果一切正常,应该可以看到 OpenGL 窗口弹出并显示出图形。
阅读全文
相关推荐


















