glow和gltools的问题,_glewInit已经定义

Problems with glew and gltools, _glewInit already defined

本文关键字:glewInit 定义 gltools 问题 glow      更新时间:2023-10-16

我正试图从opengl Superbible示例添加着色器到我的程序。问题是,当我从gltools调用任何函数时,我得到

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

之后,我交换了glew32。使用glew32 . 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();
}

当我尝试使用

        GLfloat modmatrix[16], projmatrix[16];
    glGetFloatv(GL_PROJECTION_MATRIX, projmatrix);
    glGetFloatv(GL_MODELVIEW_MATRIX, modmatrix);
    //M3DMatrix44f
    float MDWPRJMatrix[16];
    m3dMatrixMultiply44(MDWPRJMatrix, modmatrix, projmatrix);
    glUniformMatrix4fv(locMVP, 1, GL_FALSE, MDWPRJMatrix);

我得到断言失败表达式:OPENGLUT_READY

我想知道是什么原因造成的,如果可能的话,如何解决它提前感谢

通过链接glew32s解决。lib和添加#define GLEW_STATIC在我的代码的开始。此外,链接的freeglut,而不是openglut。