w10環境vs2017,vs2019配置Opengl快捷方法

      最近,計算機圖形學老師向咱們佈置了任務,配置本身的opengl。百度以後我發現不少教程和方法嘗試以後,我發現一種簡單的方法來分享給你們。php

      首先個人軟件配置是w10專業版系統+Visual Stdio 2019社區版,通過實際測試vs2017社區版也能正經常使用。oop

  第一種方法,vs2019默認安裝就行測試

    1. VS2019建立C++控制檯程序,最好選擇空項目spa

    2. 建立好了項目,點擊菜單欄的「項目」下的「管理Nuget程序包」code

    3. 「瀏覽」下輸入NupenGL,兩個都點擊安裝orm

    4. 新建一個C++源文件
      blog

    5. 輸入下面的代碼,運行F5。教程

    6. #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; }
    7. 步驟正確,會出現以下圖案。

 

  第二種方法。ip

  1. 下載OpenGL
  2. 打開網址:https://www.opengl.org/resources/libraries/glut/glut_downloads.php
  3. 找到標題爲 GLUT for Microsoft Windows 9X, ME, 2000, NT & XP users,下面有:
  4. 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)。
  5. 點擊 glutdlls37beta.zip 便可下載。
  6. 配置OpenGL
  7. 將下載的 glutdlls37beta.zip 解壓可發現裏面包含 glut.dll glut32.dll glut.lib glut32.lib glut.h 5個文件。
  8. 而後找到vs2017安裝的目錄,路徑爲 (D:\Program)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include ,建立一個名爲gl的文件夾,並將解壓到的glut.h文件複製其中。
  9. 再找到路徑爲 (D:\Program)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\lib\x86 ,將解壓到的glut.lib,glut32.lib複製其中。
  10. 最後把解壓到的glut.dll和glut32.dll複製到C:\Windows\System32文件夾內(32位系統)或C:\Windows\SysWOW64(64位系統)。
  11. 測試和上面一種相同。
相關文章
相關標籤/搜索