2016-03-18 165 views
-3

我想學習使用着色器,因此在Netbeans(ver。8.0.2)上創建了一個新的C++項目。OpenGL GLFW/GLEW編程

我想包括GLFW和GLEW庫就像在本教程中指出:http://www.learnopengl.com/#!Getting-started/Creating-a-window

我目前struggeling在正常進口GLEW。當使用#include <GL/glew.h>時,編譯器(我在Windows10x64/Cygwin控制檯上使用GNU g ++)會引發大量錯誤。這似乎是glu.h的問題。爲了測試的目的,我去掉了glew.h中的glu.h。這消除了錯誤,但也阻止了openGL完全加載(以gl開頭的函數「未定義」,如glViewport)。所以這不可能是解決方案。

輸出呼籲正常glew.h編譯時,我得到:

g++ -m64 -c -g -Wall -I/cygdrive/C/Users/Erik/programming/Libraries/glew-1.13.0-win32/glew-1.13.0/include/ -I/cygdrive/C/Users/Erik/programming/Libraries/glfw-3.1.2.bin.WIN32/glfw-3.1.2.bin.WIN32/include/ -std=c++11 -MMD -MP -MF "build/Debug/Cygwin-Windows/startup.o.d" -o build/Debug/Cygwin-Windows/startup.o startup.cc 

In file included from /cygdrive/C/Users/Erik/programming/Libraries/glew-1.13.0-win32/glew-1.13.0/include/GL/glew.h:1202:0, 
       from startup.cc:5: 
/usr/include/w32api/GL/glu.h:68:79: error: expected ')' before '*' token 
void APIENTRY gluQuadricCallback(GLUquadric *qobj,GLenum which,void (CALLBACK *fn)()); 
                      ^
/usr/include/w32api/GL/glu.h:68:79: error: expected ')' before '*' token 
/usr/include/w32api/GL/glu.h:68:79: error: expected initializer before '*' token 
/usr/include/w32api/GL/glu.h:78:79: error: expected ')' before '*' token 
void APIENTRY gluTessCallback(GLUtesselator *tess,GLenum which,void (CALLBACK *fn)()); 
                      ^
/usr/include/w32api/GL/glu.h:78:79: error: expected ')' before '*' token 
/usr/include/w32api/GL/glu.h:78:79: error: expected initializer before '*' token 
/usr/include/w32api/GL/glu.h:94:75: error: expected ')' before '*' token 
void APIENTRY gluNurbsCallback(GLUnurbs *nobj,GLenum which,void (CALLBACK *fn)()); 
                     ^
/usr/include/w32api/GL/glu.h:94:75: error: expected ')' before '*' token 
/usr/include/w32api/GL/glu.h:94:75: error: expected initializer before '*' token 
/usr/include/w32api/GL/glu.h:96:24: error: expected ')' before '*' token 
typedef void (CALLBACK *GLUquadricErrorProc)(GLenum); 
         ^
/usr/include/w32api/GL/glu.h:97:24: error: expected ')' before '*' token 
typedef void (CALLBACK *GLUtessBeginProc)(GLenum); 
         ^
/usr/include/w32api/GL/glu.h:98:24: error: expected ')' before '*' token 
typedef void (CALLBACK *GLUtessEdgeFlagProc) (GLboolean); 
         ^
/usr/include/w32api/GL/glu.h:99:24: error: expected ')' before '*' token 
typedef void (CALLBACK *GLUtessVertexProc)(void *); 
         ^
/usr/include/w32api/GL/glu.h:100:24: error: expected ')' before '*' token 
typedef void (CALLBACK *GLUtessEndProc)(void); 
         ^
/usr/include/w32api/GL/glu.h:101:24: error: expected ')' before '*' token 
typedef void (CALLBACK *GLUtessErrorProc)(GLenum); 
         ^
/usr/include/w32api/GL/glu.h:102:24: error: expected ')' before '*' token 
typedef void (CALLBACK *GLUtessCombineProc)(GLdouble[3],void*[4],GLfloat[4],void**); 
         ^
/usr/include/w32api/GL/glu.h:103:24: error: expected ')' before '*' token 
typedef void (CALLBACK *GLUtessBeginDataProc)(GLenum,void *); 
         ^
/usr/include/w32api/GL/glu.h:104:24: error: expected ')' before '*' token 
typedef void (CALLBACK *GLUtessEdgeFlagDataProc) (GLboolean,void *); 
         ^
/usr/include/w32api/GL/glu.h:105:24: error: expected ')' before '*' token 
typedef void (CALLBACK *GLUtessVertexDataProc)(void *,void *); 
         ^
/usr/include/w32api/GL/glu.h:106:24: error: expected ')' before '*' token 
typedef void (CALLBACK *GLUtessEndDataProc)(void *); 
         ^
/usr/include/w32api/GL/glu.h:107:24: error: expected ')' before '*' token 
typedef void (CALLBACK *GLUtessErrorDataProc)(GLenum,void *); 
         ^
/usr/include/w32api/GL/glu.h:108:24: error: expected ')' before '*' token 
typedef void (CALLBACK *GLUtessCombineDataProc)(GLdouble[3],void*[4],GLfloat[4],void**,void*); 
         ^
/usr/include/w32api/GL/glu.h:109:24: error: expected ')' before '*' token 
typedef void (CALLBACK *GLUnurbsErrorProc)(GLenum); 
         ^

對我來說,(我是用C無親++,因此不會在解釋錯誤消息非常好)好像CALLBACK尚未定義。任何想法如何解決這個問題?

+0

沒有語言的C/C++。只有兩種不同的**語言C和C++。選擇你實際使用的那個! – Olaf

+0

不要只使用鏈接。一個問題需要自成一體。學習[問]。 – Olaf

+0

你能展示一個代碼無法編譯的最小例子嗎? – Louen

回答

0

我解決它以某種方式(不漂亮,但至少以某種方式):

我試圖導入windef.hlink from @Louen說明。 這刪除了CALLBACK-Error,但創建了一個新的(關於APIENTRY的東西)。所以,我搜索了WINDEF.H的錯誤,解決一部分,並發現它:

#ifndef CALLBACK 
#if defined(_ARM_) 
#define CALLBACK 
#else 
#define CALLBACK __stdcall 
#endif 
#endif 

然後我就粘貼這在我的文件(而不是包括全WINDEF.H)。