opengl super bible第五个例子设置问题

时间:2017-10-27 14:37:57

标签: c++ opengl visual-studio-2015

我正在使用VS2015,并尝试了解opengl。 但不知何故,我在opengl super bible 5th中的第一个例子triangle.cpp遇到了一些问题。 我谷歌2个小时仍然被困在这里。

以下是代码:

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

#include <Windows.h>
#include <GLTools.h>            // OpenGL toolkit
#include <GLShaderManager.h>    // Shader Manager Class
#include <GL\glew.h>
#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;
}

我得到了这些错误:

Error   LNK2019 unresolved external symbol "public: virtual __thiscall GLBatch::~GLBatch(void)" (??1GLBatch@@UAE@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'triangleBatch''(void)" (??__FtriangleBatch@@YAXXZ)    Opengl_Test C:\Users\sj88e\Documents\Visual Studio 2015\Projects\OpenGL_Test\Opengl_Test\main.obj   1   
Error   LNK2019 unresolved external symbol _glewInit@0 referenced in function _main Opengl_Test C:\Users\sj88e\Documents\Visual Studio 2015\Projects\OpenGL_Test\Opengl_Test\main.obj   1   
Error   LNK2019 unresolved external symbol _glewGetErrorString@4 referenced in function _main   Opengl_Test C:\Users\sj88e\Documents\Visual Studio 2015\Projects\OpenGL_Test\Opengl_Test\main.obj   1   
Error   LNK2019 unresolved external symbol "public: __thiscall GLBatch::GLBatch(void)" (??0GLBatch@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for 'triangleBatch''(void)" (??__EtriangleBatch@@YAXXZ)   Opengl_Test C:\Users\sj88e\Documents\Visual Studio 2015\Projects\OpenGL_Test\Opengl_Test\main.obj   1   
Error   LNK2019 unresolved external symbol "public: void __thiscall GLBatch::Begin(unsigned int,unsigned int,unsigned int)" (?Begin@GLBatch@@QAEXIII@Z) referenced in function "void __cdecl SetupRC(void)" (?SetupRC@@YAXXZ)   Opengl_Test C:\Users\sj88e\Documents\Visual Studio 2015\Projects\OpenGL_Test\Opengl_Test\main.obj   1   
Error   LNK2019 unresolved external symbol "public: void __thiscall GLBatch::End(void)" (?End@GLBatch@@QAEXXZ) referenced in function "void __cdecl SetupRC(void)" (?SetupRC@@YAXXZ)    Opengl_Test C:\Users\sj88e\Documents\Visual Studio 2015\Projects\OpenGL_Test\Opengl_Test\main.obj   1   
Error   LNK2019 unresolved external symbol "public: void __thiscall GLBatch::CopyVertexData3f(float (*)[3])" (?CopyVertexData3f@GLBatch@@QAEXPAY02M@Z) referenced in function "public: void __thiscall GLBatch::CopyVertexData3f(float *)" (?CopyVertexData3f@GLBatch@@QAEXPAM@Z)   Opengl_Test C:\Users\sj88e\Documents\Visual Studio 2015\Projects\OpenGL_Test\Opengl_Test\main.obj   1   
Error   LNK2019 unresolved external symbol "public: virtual void __thiscall GLBatch::Draw(void)" (?Draw@GLBatch@@UAEXXZ) referenced in function "void __cdecl RenderScene(void)" (?RenderScene@@YAXXZ)  Opengl_Test C:\Users\sj88e\Documents\Visual Studio 2015\Projects\OpenGL_Test\Opengl_Test\main.obj   1   
Error   LNK2019 unresolved external symbol "public: __thiscall GLShaderManager::GLShaderManager(void)" (??0GLShaderManager@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for 'shaderManager''(void)" (??__EshaderManager@@YAXXZ)   Opengl_Test C:\Users\sj88e\Documents\Visual Studio 2015\Projects\OpenGL_Test\Opengl_Test\main.obj   1   
Error   LNK2019 unresolved external symbol "public: __thiscall GLShaderManager::~GLShaderManager(void)" (??1GLShaderManager@@QAE@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'shaderManager''(void)" (??__FshaderManager@@YAXXZ)    Opengl_Test C:\Users\sj88e\Documents\Visual Studio 2015\Projects\OpenGL_Test\Opengl_Test\main.obj   1   
Error   LNK2019 unresolved external symbol "public: bool __thiscall GLShaderManager::InitializeStockShaders(void)" (?InitializeStockShaders@GLShaderManager@@QAE_NXZ) referenced in function "void __cdecl SetupRC(void)" (?SetupRC@@YAXXZ) Opengl_Test C:\Users\sj88e\Documents\Visual Studio 2015\Projects\OpenGL_Test\Opengl_Test\main.obj   1   
Error   LNK2019 unresolved external symbol "public: int __cdecl GLShaderManager::UseStockShader(enum GLT_STOCK_SHADER,...)" (?UseStockShader@GLShaderManager@@QAAHW4GLT_STOCK_SHADER@@ZZ) referenced in function "void __cdecl RenderScene(void)" (?RenderScene@@YAXXZ) Opengl_Test C:\Users\sj88e\Documents\Visual Studio 2015\Projects\OpenGL_Test\Opengl_Test\main.obj   1   
Error   LNK2019 unresolved external symbol "void __cdecl gltSetWorkingDirectory(char const *)" (?gltSetWorkingDirectory@@YAXPBD@Z) referenced in function _main Opengl_Test C:\Users\sj88e\Documents\Visual Studio 2015\Projects\OpenGL_Test\Opengl_Test\main.obj   1   
Error   LNK1120 13 unresolved externals Opengl_Test C:\Users\sj88e\Documents\Visual Studio 2015\Projects\OpenGL_Test\Debug\Opengl_Test.exe  1   

我已经完成了有关包含头文件,库和dll的所有说明。 我该如何解决这个问题?

编辑: 我将所有头文件添加到VC / lib文件夹和VC / lib文件夹中的库中。

Property Pages->VC++ Directories->include Directories

Property Pages->VC++ Directories->Library Directories

我认为它可以通过此设置进行链接,我可以在第2版中运行一些示例。我误解了什么吗?

0 个答案:

没有答案