2011-07-19 85 views
4

最近我得到了OpenGL SuperBible第5版。所有的開心我開始閱讀,當我到達第一部分關於如何正確設置所有內容時,我遇到了一些Google和其他StackOverflow問題無法回答的問題。OpenGL SuperBible標題問題

我想澄清一點,我使用Visual Studio 2010並且所有內容都鏈接正確。

我已經從官方的OpenGL Superbible網站下載了庫和頭文件。

所以當我編寫第一個叫做Triangle.cpp的程序並嘗試編譯它時,它會給出下列錯誤。

1>------ Build started: Project: OpenGL, Configuration: Debug Win32 ------ 
1>Build started 7/19/2011 9:21:27 PM. 
1>InitializeBuildStatus: 
1> Touching "Debug\OpenGL.unsuccessfulbuild". 
1>ClCompile: 
1> Triangle.cpp 
1>c:\sb5\src\gltools\include\glbatch.h(77): error C2061: syntax error : identifier 'GLenum' 
1>c:\sb5\src\gltools\include\glbatch.h(86): error C2061: syntax error : identifier 'GLuint' 
1>c:\sb5\src\gltools\include\glbatch.h(89): error C2061: syntax error : identifier 'GLfloat' 
1>c:\sb5\src\gltools\include\glbatch.h(90): error C2061: syntax error : identifier 'GLfloat' 
1>c:\sb5\src\gltools\include\glbatch.h(91): error C2061: syntax error : identifier 'GLfloat' 
1>c:\sb5\src\gltools\include\glbatch.h(92): error C2061: syntax error : identifier 'GLfloat' 
1>c:\sb5\src\gltools\include\glbatch.h(100): error C2061: syntax error : identifier 'GLfloat' 
1>c:\sb5\src\gltools\include\glbatch.h(103): error C2061: syntax error : identifier 'GLfloat' 
1>c:\sb5\src\gltools\include\glbatch.h(106): error C2061: syntax error : identifier 'GLfloat' 
1>c:\sb5\src\gltools\include\glbatch.h(109): error C2061: syntax error : identifier 'GLuint' 
1>c:\sb5\src\gltools\include\glbatch.h(110): error C2061: syntax error : identifier 'GLuint' 
1>c:\sb5\src\gltools\include\glbatch.h(113): error C2146: syntax error : missing ';' before identifier 'primitiveType' 
1>c:\sb5\src\gltools\include\glbatch.h(113): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(113): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(115): error C2146: syntax error : missing ';' before identifier 'uiVertexArray' 
1>c:\sb5\src\gltools\include\glbatch.h(115): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(115): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(116): error C2146: syntax error : missing ';' before identifier 'uiNormalArray' 
1>c:\sb5\src\gltools\include\glbatch.h(116): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(116): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(117): error C2146: syntax error : missing ';' before identifier 'uiColorArray' 
1>c:\sb5\src\gltools\include\glbatch.h(117): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(117): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(118): error C2143: syntax error : missing ';' before '*' 
1>c:\sb5\src\gltools\include\glbatch.h(118): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(118): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(119): error C2146: syntax error : missing ';' before identifier 'vertexArrayObject' 
1>c:\sb5\src\gltools\include\glbatch.h(119): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(119): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(121): error C2146: syntax error : missing ';' before identifier 'nVertsBuilding' 
1>c:\sb5\src\gltools\include\glbatch.h(121): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(121): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(122): error C2146: syntax error : missing ';' before identifier 'nNumVerts' 
1>c:\sb5\src\gltools\include\glbatch.h(122): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(122): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(123): error C2146: syntax error : missing ';' before identifier 'nNumTextureUnits' 
1>c:\sb5\src\gltools\include\glbatch.h(123): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(123): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glbatch.h(89): error C2065: 'vVerts' : undeclared identifier 
1>c:\sb5\src\gltools\include\glbatch.h(90): error C2065: 'vNorms' : undeclared identifier 
1>c:\sb5\src\gltools\include\glbatch.h(91): error C2065: 'vColors' : undeclared identifier 
1>c:\sb5\src\gltools\include\glbatch.h(92): error C2065: 'vTex' : undeclared identifier 
1>c:\sb5\src\gltools\include\glbatch.h(92): error C2065: 'uiTextureLayer' : undeclared identifier 
1>c:\sb5\src\gltools\include\glshadermanager.h(85): error C2146: syntax error : missing ';' before identifier 'uiShaderID' 
1>c:\sb5\src\gltools\include\glshadermanager.h(85): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(85): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(99): error C2146: syntax error : missing ';' before identifier 'GetStockShader' 
1>c:\sb5\src\gltools\include\glshadermanager.h(99): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(99): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(99): warning C4183: 'GetStockShader': missing return type; assumed to be a member function returning 'int' 
1>c:\sb5\src\gltools\include\glshadermanager.h(102): error C2146: syntax error : missing ';' before identifier 'UseStockShader' 
1>c:\sb5\src\gltools\include\glshadermanager.h(102): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(102): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(102): warning C4183: 'UseStockShader': missing return type; assumed to be a member function returning 'int' 
1>c:\sb5\src\gltools\include\glshadermanager.h(107): error C2146: syntax error : missing ';' before identifier 'LoadShaderPair' 
1>c:\sb5\src\gltools\include\glshadermanager.h(107): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(107): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(107): warning C4183: 'LoadShaderPair': missing return type; assumed to be a member function returning 'int' 
1>c:\sb5\src\gltools\include\glshadermanager.h(110): error C2146: syntax error : missing ';' before identifier 'LoadShaderPairSrc' 
1>c:\sb5\src\gltools\include\glshadermanager.h(110): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(110): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(110): warning C4183: 'LoadShaderPairSrc': missing return type; assumed to be a member function returning 'int' 
1>c:\sb5\src\gltools\include\glshadermanager.h(113): error C2146: syntax error : missing ';' before identifier 'LoadShaderPairWithAttributes' 
1>c:\sb5\src\gltools\include\glshadermanager.h(113): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(113): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(113): warning C4183: 'LoadShaderPairWithAttributes': missing return type; assumed to be a member function returning 'int' 
1>c:\sb5\src\gltools\include\glshadermanager.h(114): error C2146: syntax error : missing ';' before identifier 'LoadShaderPairSrcWithAttributes' 
1>c:\sb5\src\gltools\include\glshadermanager.h(114): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(114): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(114): warning C4183: 'LoadShaderPairSrcWithAttributes': missing return type; assumed to be a member function returning 'int' 
1>c:\sb5\src\gltools\include\glshadermanager.h(117): error C2146: syntax error : missing ';' before identifier 'LookupShader' 
1>c:\sb5\src\gltools\include\glshadermanager.h(117): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(117): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(117): warning C4183: 'LookupShader': missing return type; assumed to be a member function returning 'int' 
1>c:\sb5\src\gltools\include\glshadermanager.h(120): error C2146: syntax error : missing ';' before identifier 'uiStockShaders' 
1>c:\sb5\src\gltools\include\glshadermanager.h(120): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\glshadermanager.h(120): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(96): error C2061: syntax error : identifier 'GLuint' 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(101): error C2146: syntax error : missing ';' before identifier 'GetIndexCount' 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(101): error C2433: 'GLTriangleBatch::GLuint' : 'inline' not permitted on data declarations 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(101): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(101): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(101): warning C4183: 'GetIndexCount': missing return type; assumed to be a member function returning 'int' 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(102): error C2146: syntax error : missing ';' before identifier 'GetVertexCount' 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(102): error C2433: 'GLTriangleBatch::GLuint' : 'inline' not permitted on data declarations 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(102): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(102): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(102): warning C4183: 'GetVertexCount': missing return type; assumed to be a member function returning 'int' 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(109): error C2143: syntax error : missing ';' before '*' 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(109): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(109): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(114): error C2146: syntax error : missing ';' before identifier 'nMaxIndexes' 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(114): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(114): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(115): error C2146: syntax error : missing ';' before identifier 'nNumIndexes' 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(115): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(115): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(116): error C2146: syntax error : missing ';' before identifier 'nNumVerts' 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(116): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(116): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(118): error C2146: syntax error : missing ';' before identifier 'bufferObjects' 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(118): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(118): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(119): error C2146: syntax error : missing ';' before identifier 'vertexArrayBufferObject' 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(119): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(119): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(101): error C2065: 'nNumIndexes' : undeclared identifier 
1>c:\sb5\src\gltools\include\gltrianglebatch.h(102): error C2065: 'nNumVerts' : undeclared identifier 
1>c:\sb5\src\gltools\include\gltools.h(144): error C2065: 'GLint' : undeclared identifier 
1>c:\sb5\src\gltools\include\gltools.h(144): error C2065: 'nMajor' : undeclared identifier 
1>c:\sb5\src\gltools\include\gltools.h(144): error C2065: 'GLint' : undeclared identifier 
1>c:\sb5\src\gltools\include\gltools.h(144): error C2065: 'nMinor' : undeclared identifier 
1>c:\sb5\src\gltools\include\gltools.h(144): error C2182: 'gltGetOpenGLVersion' : illegal use of type 'void' 
1>c:\sb5\src\gltools\include\gltools.h(144): error C2078: too many initializers 
1>c:\sb5\src\gltools\include\gltools.h(153): error C2143: syntax error : missing ';' before '*' 
1>c:\sb5\src\gltools\include\gltools.h(153): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltools.h(153): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltools.h(157): error C2143: syntax error : missing ';' before '*' 
1>c:\sb5\src\gltools\include\gltools.h(157): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltools.h(157): error C2086: 'int GLbyte' : redefinition 
1>   c:\sb5\src\gltools\include\gltools.h(153) : see declaration of 'GLbyte' 
1>c:\sb5\src\gltools\include\gltools.h(157): error C2061: syntax error : identifier 'GLint' 
1>c:\sb5\src\gltools\include\gltools.h(157): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltools.h(162): error C2146: syntax error : missing ';' before identifier 'gltGrabScreenTGA' 
1>c:\sb5\src\gltools\include\gltools.h(162): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltools.h(162): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltools.h(167): error C2061: syntax error : identifier 'GLfloat' 
1>c:\sb5\src\gltools\include\gltools.h(168): error C2061: syntax error : identifier 'GLfloat' 
1>c:\sb5\src\gltools\include\gltools.h(169): error C2061: syntax error : identifier 'GLfloat' 
1>c:\sb5\src\gltools\include\gltools.h(170): error C2061: syntax error : identifier 'GLfloat' 
1>c:\sb5\src\gltools\include\gltools.h(171): error C2061: syntax error : identifier 'GLfloat' 
1>c:\sb5\src\gltools\include\gltools.h(174): error C2061: syntax error : identifier 'GLuint' 
1>c:\sb5\src\gltools\include\gltools.h(175): error C2061: syntax error : identifier 'GLuint' 
1>c:\sb5\src\gltools\include\gltools.h(177): error C2146: syntax error : missing ';' before identifier 'gltLoadShaderPair' 
1>c:\sb5\src\gltools\include\gltools.h(177): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltools.h(177): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltools.h(178): error C2146: syntax error : missing ';' before identifier 'gltLoadShaderPairWithAttributes' 
1>c:\sb5\src\gltools\include\gltools.h(178): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltools.h(178): error C2086: 'int GLuint' : redefinition 
1>   c:\sb5\src\gltools\include\gltools.h(177) : see declaration of 'GLuint' 
1>c:\sb5\src\gltools\include\gltools.h(178): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltools.h(180): error C2146: syntax error : missing ';' before identifier 'gltLoadShaderPairSrc' 
1>c:\sb5\src\gltools\include\gltools.h(180): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltools.h(180): error C2086: 'int GLuint' : redefinition 
1>   c:\sb5\src\gltools\include\gltools.h(177) : see declaration of 'GLuint' 
1>c:\sb5\src\gltools\include\gltools.h(180): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltools.h(181): error C2146: syntax error : missing ';' before identifier 'gltLoadShaderPairSrcWithAttributes' 
1>c:\sb5\src\gltools\include\gltools.h(181): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltools.h(181): error C2086: 'int GLuint' : redefinition 
1>   c:\sb5\src\gltools\include\gltools.h(177) : see declaration of 'GLuint' 
1>c:\sb5\src\gltools\include\gltools.h(181): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\sb5\src\gltools\include\gltools.h(183): error C2146: syntax error : missing ')' before identifier 'progName' 
1>c:\sb5\src\gltools\include\gltools.h(183): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning) 
1>c:\sb5\src\gltools\include\gltools.h(183): error C2059: syntax error : ')' 
1>c:\sb5\src\gltools\include\gltools.h(184): error C2146: syntax error : missing ')' before identifier 'width' 
1>c:\sb5\src\gltools\include\gltools.h(184): error C2182: 'gltGenerateOrtho2DMat' : illegal use of type 'void' 
1>c:\sb5\src\gltools\include\gltools.h(184): error C2059: syntax error : ')' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(46): error C2378: 'GLbyte' : redefinition; symbol cannot be overloaded with a typedef 
1>   c:\sb5\src\gltools\include\gltools.h(153) : see declaration of 'GLbyte' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(48): error C2378: 'GLint' : redefinition; symbol cannot be overloaded with a typedef 
1>   c:\sb5\src\gltools\include\gltools.h(162) : see declaration of 'GLint' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(52): error C2378: 'GLuint' : redefinition; symbol cannot be overloaded with a typedef 
1>   c:\sb5\src\gltools\include\gltools.h(177) : see declaration of 'GLuint' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1154): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1154): error C2143: syntax error : missing ',' before '*' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1155): error C2146: syntax error : missing ')' before identifier 'i' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1155): warning C4229: anachronism used : modifiers on data are ignored 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1155): error C2182: 'glArrayElement' : illegal use of type 'void' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1155): error C2491: 'glArrayElement' : definition of dllimport data not allowed 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1155): error C2059: syntax error : ')' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1157): error C2061: syntax error : identifier 'GLuint' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1160): error C2146: syntax error : missing ')' before identifier 'list' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1160): warning C4229: anachronism used : modifiers on data are ignored 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1160): error C2182: 'glCallList' : illegal use of type 'void' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1160): error C2491: 'glCallList' : definition of dllimport data not allowed 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1160): error C2059: syntax error : ')' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1167): error C2146: syntax error : missing ')' before identifier 's' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1167): warning C4229: anachronism used : modifiers on data are ignored 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1167): error C2182: 'glClearStencil' : illegal use of type 'void' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1167): error C2491: 'glClearStencil' : definition of dllimport data not allowed 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1167): error C2059: syntax error : ')' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1169): error C2146: syntax error : missing ')' before identifier 'red' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1169): warning C4229: anachronism used : modifiers on data are ignored 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1169): error C2182: 'glColor3b' : illegal use of type 'void' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1169): error C2491: 'glColor3b' : definition of dllimport data not allowed 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1169): error C2059: syntax error : ')' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1170): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1170): error C2143: syntax error : missing ',' before '*' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1175): error C2146: syntax error : missing ')' before identifier 'red' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1175): warning C4229: anachronism used : modifiers on data are ignored 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1175): error C2182: 'glColor3i' : illegal use of type 'void' 
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl\gl.h(1175): fatal error C1003: error count exceeds 100; stopping compilation 
1> 
1>Build FAILED. 
1> 
1>Time Elapsed 00:00:00.67 
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

它似乎有一個標題本身的問題,即使我從官方網站下載它們。我也嘗試在Visual Studio 2010 C++ Express中編譯相同的代碼併發生相同的錯誤。我不想使用Code :: blocks,因爲我發現使用類似的東西沒有任何優勢。這一切似乎都是一件麻煩事。我更喜歡在Visual Studio中工作。

編輯(添加源代碼):

// Triangle.cpp 
// Our first OpenGL program that will just draw a triangle on the screen. 

#include <GLTools.h>   // OpenGL toolkit 
#include <GLShaderManager.h> // Shader Manager Class 

#ifdef __APPLE__ 
#include <glut/glut.h>   // OS X version of GLUT 
#else 
#define FREEGLUT_STATIC 
#include <GL/glut.h>   // Windows FreeGlut equivalent 
#endif 

GLBatch triangleBatch; 
GLShaderManager shaderManager; 

/////////////////////////////////////////////////////////////////////////////// 
// Window has changed size, or has just been created. In either case, we need 
// to use the window dimensions to set the viewport and the projection matrix. 
void ChangeSize(int w, int h) 
{ 
    glViewport(0, 0, w, h); 
} 


/////////////////////////////////////////////////////////////////////////////// 
// This function does any needed initialization on the rendering context. 
// This is the first opportunity to do any OpenGL related tasks. 
void SetupRC() 
{ 
    // Blue background 
    glClearColor(0.0f, 0.0f, 1.0f, 1.0f); 

    shaderManager.InitializeStockShaders(); 

    // Load up a triangle 
    GLfloat vVerts[] = { -0.5f, 0.0f, 0.0f, 
          0.5f, 0.0f, 0.0f, 
          0.0f, 0.5f, 0.0f }; 

    triangleBatch.Begin(GL_TRIANGLES, 3); 
    triangleBatch.CopyVertexData3f(vVerts); 
    triangleBatch.End(); 
} 



/////////////////////////////////////////////////////////////////////////////// 
// Called to draw scene 
void RenderScene(void) 
{ 
    // Clear the window with current clearing color 
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 

    GLfloat vRed[] = { 1.0f, 0.0f, 0.0f, 1.0f }; 
    shaderManager.UseStockShader(GLT_SHADER_IDENTITY, vRed); 
    triangleBatch.Draw(); 

    // Perform the buffer swap to display back buffer 
    glutSwapBuffers(); 
} 


/////////////////////////////////////////////////////////////////////////////// 
// Main entry point for GLUT based programs 
int main(int argc, char* argv[]) 
{ 
    gltSetWorkingDirectory(argv[0]); 

    glutInit(&argc, argv); 
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL); 
    glutInitWindowSize(800, 600); 
    glutCreateWindow("Triangle"); 
    glutReshapeFunc(ChangeSize); 
    glutDisplayFunc(RenderScene); 

    GLenum err = glewInit(); 
    if (GLEW_OK != err) { 
     fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); 
     return 1; 
    } 

    SetupRC(); 

    glutMainLoop(); 
    return 0; 
} 
+0

你能告訴我們你的代碼嗎?我假設在這裏,但是你在glbatch.h之後加入了windows.h嗎? – Bart

+0

知道我忘了一些東西!一旦我弄清楚如何編輯,我會這樣做。另外,我沒有。 – Frank

+0

你可能不得不告訴編譯器你正在包含的頭文件是帶有extern「C」的C風格{#include「gl.h」} –

回答

6

你看到不經常出現的OpenGL時,在Windows操作系統上的用戶首次開始開發自己的軟件中的錯誤。雖然在這種情況下,錯誤信息被glbatch.h稍微遮蔽,通常錯誤將指向gl.h。

如果您使用的是Windows,請確保您在包含gl.h之前包含windows.h,或者任何其他可能間接包含gl.h的文件。

正如MSDN所述,這對於OpenGL的工作是必需的。