2012-02-19 6 views
3

私は最近、SB第5版でOpenGlの学習を開始しましたが、残念ながら彼らが提供した最初の例ではうまくいきませんでした。OpenGLは5th版をsuperbibleします。 Triangle.cpp

ここでは、コードです:

#include <GLTools.h> 
#include <GLShaderManager.h> 
#include <GL/glew.h> 
#include <GL/glut.h> 


GLShaderManager shaderManager; 
GLBatch triangleBatch; 
void ChangeSize(GLsizei w, GLsizei h); 

void ChangeSize(int w, int h){ 
    glViewport(0,0,w,h); 
} 

void SetupRC(){ 
    //background 
    glClearColor(0.0f, 0.0f, 1.0f, 1.0f); 


    shaderManager.InitializeStockShaders(); 

    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(); 

} 

void RenderScene(void){ 

    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(); 


    glutSwapBuffers(); 
} 


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; 
}  

けれども、私は、私は単に本からそれを貼り付けコピーしましたので、問題はコードにあるとは思いません。私は本の内容に含まれているライブラリを追加し、またフリー・グラスをインストールしました。だから、彼は私が必要とするすべてのヘッダーを見つけましたが、ビルドしようとすると、それ自体triangle.cppに関係しない巨大な問題のリストがあります。ここにいくつかあります:

1>c:\users\whatever\desktop\sb5\src\gltools\include\gltools.h(183): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning) 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gltools.h(183): error C2059: syntax error : ')' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gltools.h(184): error C2146: syntax error : missing ')' before identifier 'width' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gltools.h(184): error C2182: 'gltGenerateOrtho2DMat' : illegal use of type 'void' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gltools.h(184): error C2059: syntax error : ')' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(234): error C2378: 'GLuint' : redefinition; symbol cannot be overloaded with a typedef 
1>   c:\users\whatever\desktop\sb5\src\gltools\include\gltools.h(177) : see declaration of 'GLuint' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(235): error C2378: 'GLint' : redefinition; symbol cannot be overloaded with a typedef 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gltools.h(162) : see declaration of 'GLint' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(238): error C2378: 'GLbyte' : redefinition; symbol cannot be overloaded with a typedef 
1>   c:\users\whatever\desktop\sb5\src\gltools\include\gltools.h(153) : see declaration of 'GLbyte' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(804): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(804): error C2143: syntax error : missing ',' before '*' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(805): error C2146: syntax error : missing ')' before identifier 'i' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(805): warning C4229: anachronism used : modifiers on data are ignored 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(805): error C2182: 'glArrayElement' : illegal use of type 'void' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(805): error C2491: 'glArrayElement' : definition of dllimport data not allowed 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(805): error C2059: syntax error : ')' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(807): error C2061: syntax error : identifier 'GLuint' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(810): error C2146: syntax error : missing ')' before identifier 'list' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(810): warning C4229: anachronism used : modifiers on data are ignored 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(810): error C2182: 'glCallList' : illegal use of type 'void' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(810): error C2491: 'glCallList' : definition of dllimport data not allowed 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(810): error C2059: syntax error : ')' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(817): error C2146: syntax error : missing ')' before identifier 's' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(817): warning C4229: anachronism used : modifiers on data are ignored 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(817): error C2182: 'glClearStencil' : illegal use of type 'void' 
1>c:\users\whatever\desktop\sb5\src\gltools\include\gl\glew.h(817): error C2491:  'glClearStencil' : definition of dllimport data not allowed 

私は本当にこれから何もできません。ヘッダー自体にエラーがあるかのように見えます。これらのように百以上の他のヘッダーファイルからです。私は明らかに私が明らかにしようとしている問題で十分であることを願っています。何かが明確でない場合は、お気軽にお問い合わせください。私は、あなたがWindows上で作業しているので、あなたがgl.hwindows.hを含める必要があります++ 2010

+1

あなた自身のプロジェクトにコピーするのではなく、[ソースコードのダウンロード](http://code.google.com/p/oglsuperbible5/)を直接コンパイルしてみましたか? –

+1

私は持っています。そして、奇妙なことに、その特定のファイルで同じ問題が発生しても、他のプロジェクトがうまく構築され実行されるということです。 –

答えて

2

のMicrosoft Visual Cを使用しています、また

あまり曖昧であることをしようとするでしょう。あなたが含む他のヘッダーについてはわかりませんが、確認してください。違う順序で、通常、これらの警告とエラーが表示されます。

+0

うわー。そのように単純です。誰かがどこかでそれを言いたいと思うだろう。それからもう一度、本のような完全なアマチュアのための本は意図されないかもしれない。ありがとう! 1> triangle.obj:エラーLNK2019:未解決の外部シンボル "public:void __thiscall GLBatch :: End(void)"(?End @ GLBatch @@ QAEXXZ ) "function __cdecl SetupRC(void)"(?SetupRC @@ YAXXZ) で示されているようなエラーが表示されます。私はすばやく検索しましたが、これはいくつかの不足しているライブラリに関連していますか?私はすべてのものを順番に持っていると思った。何か案は? –

+0

2つ目の問題を簡単に見てみると、それ以前に似たようなことがあるようです:http://stackoverflow.com/questions/4123082/linker-error-during-opengl-superbible-tutorial要するに、リンクする必要がありますgltools.libに対して、私はその本のソースに属するライブラリと仮定しています... – Bart

+0

残念ながら、そのスレッドの提案された解決策は私のためには機能しませんでした。私は問題の範囲の横にあると思うので、「私のソリューションディレクトリにglut32.dllを含める」ビットから明記した内容をすべて完了しました。しかし、LNKのエラーは残ります –

関連する問題