+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
下载OpenGL
- 打开网址:
- 找到标题为 GLUT for Microsoft Windows 9X, ME, 2000, NT & XP users,下面有:If you want just the GLUT header file, the .LIB, and .DLL files all pre-compiled for Intel platforms, you can simply download the glutdlls37beta.zip file (149 kilobytes)。
- 点击 glutdlls37beta.zip 即可下载。
配置OpenGL
- 将下载的 glutdlls37beta.zip 解压可发现里面包含 glut.dll glut32.dll glut.lib glut32.lib glut.h 5个文件。
- 然后找到vs2017安装的目录,路径为 (C:Program File(x86))\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include ,创建一个名为gl的文件夹,并将解压到的glut.h文件复制其中。
- 再找到路径为 (C:Program File(x86))\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\lib\x86 ,将解压到的glut.lib,glut32.lib复制其中。
- 最后把解压到的glut.dll和glut32.dll复制到C:\Windows\System32文件夹内(32位系统)或C:\Windows\SysWOW64(64位系统)。
测试
- 打开vs2017,新建一个C++的Windows控制台应用程序的空项目,将如下代码粘贴:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #includevoid Show() { glClear(GL_COLOR_BUFFER_BIT); glRectf(-0.1f, -0.1f, 0.5f, 0.5f); glFlush(); } int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE); glutInitWindowPosition(100, 100); glutInitWindowSize(800, 600); glutCreateWindow("OpenGL-ONE"); glutDisplayFunc(Show); glutMainLoop(); return 0; }
如果你能成功运行如上代码,并且成功绘制了一个矩形,那么配置成功。