glew 和 gltools 的问题,_glewInit 已定义
我正在尝试将 opengl Superbible 示例中的着色器添加到我的程序中。问题是,当我从 gltools 调用任何函数时,我得到
glew32.lib(glew32.dll) : error LNK2005: _glewInit already defined in gltools.lib(glew.obj)
After this i swapped glew32.lib with 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();
}
当我尝试使用时,
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
我想知道导致此问题的原因,如果可能,如何解决它 提前致谢
I am trying to add shadders from opengl Superbible example to my program. The problem is, when I call any function from gltools i get
glew32.lib(glew32.dll) : error LNK2005: _glewInit already defined in gltools.lib(glew.obj)
After this i swapped glew32.lib with glew32s.lib. That resulted in an unhandled exception at
const M3DMatrix44f& GetMatrix(void) { return pStack[stackPointer]; }
The code I added
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();
}
When i try to work aroud with
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);
I get assertion failed with Expression:OPENGLUT_READY
I would like to know what causes this, and if possible, how to solve it
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过链接 glew32s.lib 并在代码开头添加
#define GLEW_STATIC
解决了这个问题。另外,链接的是 freeglut 而不是 openglut。Solved it by linking glew32s.lib and adding
#define GLEW_STATIC
at the beginning of my code. Also, linked freeglut instead of openglut.