gpt4 book ai didi

c++ - 对 GLShaderManager 和 GLBatch 的 undefined reference

转载 作者:行者123 更新时间:2023-11-30 17:50:34 24 4
gpt4 key购买 nike

我正在尝试从 opengl 教程编译以下程序,但出现这些奇怪的错误。我不知道如何解决这些问题,请帮忙。IDE 代码块 12.11、Windows 7 32 位、gcc 4.7.1

这是代码

#include <GLTools.h>
#include <GL/glut.h>
#include <GLShaderManager.h>
GLBatch triangleBatch;
GLShaderManager shaderManager;
void ChangeSize(int w, int h)
{
glViewport(0, 0, w, h);
}

void SetupRC()
{
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;
}

错误-

undefined reference to    GLShaderManager::InitializeStockShaders()
undefined reference to GLBatch::Begin(unsigned int, unsigned int, unsigned int)
undefined reference to GLBatch::End()
undefined reference to GLShaderManager::UseStockShader(GLT_STOCK_SHADER, ...)
undefined reference to GLBatch::Draw()
undefined reference to gltSetWorkingDirectory(char const*)
undefined reference to GLBatch::~GLBatch()
undefined reference to GLShaderManager::~GLShaderManager()
undefined reference to GLBatch::GLBatch()
undefined reference to GLShaderManager::GLShaderManager()
undefined reference to GLBatch::CopyVertexData3f(float (*) [3])
||=== Build finished: 11 errors, 0 warnings (0 minutes, 2 seconds) ===||

链接的库-lmingw32 -lglut32 -lglew32 -lglu32 -lgltools -lopengl32

最佳答案

在 GLBatch 上快速谷歌一下,我得到一个提示,您可能需要添加链接这个库以及 gltools.lib,尝试一下并让我知道。

关于c++ - 对 GLShaderManager 和 GLBatch 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17191112/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com