2011-09-25 28 views
1

我想從opengl Superbible示例添加到我的程序的shadders。問題是,當我叫任何功能從gltools我得到glew和gltools的問題,_glewInit已經定義

glew32.lib(glew32.dll) : error LNK2005: _glewInit already defined in gltools.lib(glew.obj) 

這個我換glew32.lib與glew32s.lib後。這導致了未處理的異常在

const M3DMatrix44f& GetMatrix(void) { return pStack[stackPointer]; } 

我加

void Shadders::RenderScene() 
{ 

    static CStopWatch rotTimer; 

// Clear the window and the depth buffer 
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 

modelViewMatrix.PushMatrix(viewFrame); 
    modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 10.0f, 0.0f, 1.0f, 0.0f); 

    GLfloat vColor[] = { 0.1f, 0.1f, 1.f, 1.0f }; 

    glUseProgram(flatShader); 
    glUniform4fv(locColor, 1, vColor); 
    glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix()); // The line that causes the unhandled exception 
torusBatch.Draw(); 

modelViewMatrix.PopMatrix(); 


glutSwapBuffers(); 
glutPostRedisplay(); 
} 

當我嘗試的工作和身邊與

我得到斷言的代碼無法與表達:OPENGLUT_READY

我想知道是什麼原因造成的,如果可能的話,如何解決呢 在此先感謝

回答

1

通過鏈接glew32s.lib並在我的代碼開頭處添加#define GLEW_STATIC來解決此問題。另外,鏈接freeglut而不是openglut。