[問題] 用vc++2008寫openGL

看板C_and_CPP作者 (Come to Dady!)時間15年前 (2009/04/11 21:37), 編輯推噓2(207)
留言9則, 5人參與, 最新討論串1/1
不好意思 因為不管怎麼試就是無法compile成功 我已經爬文找過了 沒有看到08版的設定怎麼做 NEHE上面也沒找到 Step 1. 抓Library 到 http://www.xmission.com/~nate/glut.html 下載 glut-x.x.x-bin.zip。 Step 2. 安裝元件 解壓縮後, 把 glut.dll 放到 C:\WINDOWS\system 下 把 glut.h 放到 C:\Program Files\Microsoft Visual Studio\VC98\Include\gl 下 把 glut.lib 放到 C:\Program Files\Microsoft Visual Studio\VC98\Lib 下 Step 3. 編譯設定 到VC的 Project->Setting->"Link" 的 Object/library modules的欄位, 增加glut32.lib glu32.lib opengl32.lib glaux.lib 。 之後再編譯就可以了。 以上這應該是6.0的作法 其中step2的三個檔案我也都找到相應的位置放好了 step3則是在程式碼加入 #include <GL/glut.h> #include <stdlib.h> #include <stdafx.h> #pragma comment (lib, "winmm.lib") /* link with Windows MultiMedia lib */ #pragma comment (lib, "opengl32.lib") /* link with Microsoft OpenGL lib */ #pragma comment (lib, "glu32.lib") /* link with OpenGL Utility lib */ #pragma comment (lib, "glut32.lib") /* link with Win32 GLUT lib */ #pragma comment (lib, "glaux.lib") 可是這樣還是無法成功 1>c:\documents and settings\fox\my documents\visual studio 2008\projects\c++ \robottest\robottest\robottest.cpp(8) : warning C4627: '#include <GL/glut.h>': skipped when looking for precompiled header use 1> Add directive to 'stdafx.h' or rebuild precompiled header 1>c:\documents and settings\fox\my documents\visual studio 2008\projects\c++ \robottest\robottest\robottest.cpp(29) : error C3861: 'glClearColor': identifier not found 請告訴我到底要怎麼做才能成功的compile出來 麻煩了 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.252.38

04/11 21:59, , 1F
gl.h glu.h也要include
04/11 21:59, 1F

04/11 22:01, , 2F
另外glut不是 opengl
04/11 22:01, 2F

04/11 22:03, , 3F
試過了 一樣耶 而且怎麼我的include檔案裡找不到
04/11 22:03, 3F

04/11 22:04, , 4F
gl.h glu.h這兩個檔案?
04/11 22:04, 4F

04/11 22:10, , 5F
VC2005在 platformsdk\include\gl 下, VC2008就不知了@@
04/11 22:10, 5F

04/11 23:48, , 6F
include <stdafx.h> 一定要放在 .cpp 的第一行 XD
04/11 23:48, 6F

04/12 00:13, , 7F
我覺得#include<glut.h>就可以了...
04/12 00:13, 7F

04/12 00:14, , 8F
欸不對 你是丟到gl的資料夾 我眼殘 sorry
04/12 00:14, 8F

04/12 00:45, , 9F
成功了 感謝六樓! 感謝大家!
04/12 00:45, 9F
文章代碼(AID): #19u9qqOk (C_and_CPP)