1. 程式人生 > >visual studio 2017 安裝 glut

visual studio 2017 安裝 glut

  • glut下載
    glut下載連結:https://www.opengl.org/resources/libraries/glut/ 【頁面中點選Pre-compiled Win32 for Intel GLUT 3.7 DLLs for Windows 95 & NT 下載】
  • 安裝
    .h檔案
    glut.h 放入路徑 D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\ 14.12.25827 (版本可能不一樣) \include\GL\,GL資料夾手動建立。
    .lib 檔案
    glut32.lib 放入路徑 D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\lib\x86
    glut.lib 放入路徑 D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\lib\x64
    .dll檔案

    為了方便,將:glut.dll 和 glut32.dll 放入C:\Windows\SysWOW64\ C:\Windows\System32\中。
  • 測試
    新建一個空專案。
#include <GL/glut.h>
void display(void) {
	glClear(GL_COLOR_BUFFER_BIT);
	glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
	glFlush();
}

int main(int argc, char *argv[]) {
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
	glutInitWindowPosition(300, 300);
	glutInitWindowSize(300, 300);
	glutCreateWindow("第一個OpenGL程式");
	glutDisplayFunc(&display);
	glutMainLoop();
	return 0;
}

結果如下,ok。
在這裡插入圖片描述