Windows10下vs2017的OpenGL的配置

来源:互联网 发布:网络大电影收入来源 编辑:程序博客网 时间:2024/05/18 02:05

Windows10下vs2017的OpenGL的配置

有关Windows10下vs2017的OpenGL如何配置,可参照如下方法:

目录

[TOC]来生成目录:

  • Windows10下vs2017的OpenGL的配置
    • 目录
    • 下载OpenGL
    • 配置OpenGL
    • 测试
    • 最后


下载OpenGL

  • 打开网址:https://www.opengl.org/resources/libraries/glut/glut_downloads.php
  • 找到标题为 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安装的目录,路径为 (D:\Program)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include ,创建一个名为gl的文件夹,并将解压到的glut.h文件复制其中。
  • 再找到路径为 (D:\Program)\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控制台应用程序的空项目,将如下代码粘贴:

#include <GL/glut.h>void 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;}

最后

如果你能成功运行如上代码,并且成功绘制了一个矩形,那么恭喜你,配置成功!
否则,就重新配喽~


王巍
2017年11月01日

原创粉丝点击