首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在qopenglfunctions.h中找不到glGenBuffers、glBindBuffer等。

在qopenglfunctions.h中找不到glGenBuffers、glBindBuffer等。
EN

Stack Overflow用户
提问于 2013-11-13 19:56:58
回答 1查看 2.3K关注 0票数 4

我试图用opengl使用着色器在qt5.1.1中编写一个地图应用程序。我可以用Glew显示顶点。但是我想使用qopenglfunctions.h中提供的函数,h奇怪的是,即使我包含了这个文件,我也没有在这个范围内声明glGenBuffers。当我打开qopenglfunctions.h .h,它就在那个文件里!有人遇到过这个奇怪的问题吗?代码相当长。但我增加了一些,它抛出了链接器错误。

代码语言:javascript
复制
initializeGLFunctions();
this->program=program;

glGenVertexArrays(1,&mapVAO); //This is where the linker throws an error
glBindVertexArray(mapVAO);

// Generate 2 VBOs
glGenBuffers(2, mapBuffer);
initMapBoundary();


void GeometryEngine::initMapBoundary()
{
     GLfloat mapSize=5.0f;
  VertexData boundary[] = {
    // Vertex data for face 0
    {QVector3D(-mapSize, -mapSize,  1.0), QVector2D(0, 0)},  // v0
    {QVector3D( mapSize, -mapSize,  1.0), QVector2D(20.0,0/*0.33, 0.0*/)}, // v1
    {QVector3D(-mapSize,  mapSize,  1.0), QVector2D(0,20/*0.0, 0.5*/)},  // v2
    {QVector3D( mapSize,  mapSize,  1.0), QVector2D(20.0,20.0/*0.33, 0.5*/)}, // v3
};


GLushort indices[] = {
    0,  1,  2,  3,
};


// Transfer vertex data to VBO 0
glBindBuffer(GL_ARRAY_BUFFER, mapBuffer[0]);
glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(VertexData), boundary, GL_STATIC_DRAW);

// Transfer index data to VBO 1
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mapBuffer[1]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, 4 * sizeof(GLushort), indices, GL_STATIC_DRAW);

// Offset for position
quintptr offset = 0;

// Tell OpenGL programmable pipeline how to locate vertex position data
int vertexLocation = program->attributeLocation("a_position");
program->enableAttributeArray(vertexLocation);
// program->setAttributeBuffer(vertexLocation,GL_FLOAT,offset,3);
glVertexAttribPointer(vertexLocation, 3, GL_FLOAT, GL_FALSE, sizeof(VertexData), (const void *)offset);

// Offset for texture coordinate
offset += sizeof(QVector3D);

// Tell OpenGL programmable pipeline how to locate vertex texture coordinate data
int texcoordLocation = program->attributeLocation("a_texcoord");
program->enableAttributeArray(texcoordLocation);
glVertexAttribPointer(texcoordLocation, 2, GL_FLOAT, GL_FALSE, sizeof(VertexData), (const void *)offset);
//program->setAttributeBuffer(texcoordLocation,GL_FLOAT,offset,2);
}

就像我说的,所有这些在我的linux机器上都很好,所以我确信代码没有什么问题。我只需要知道如何告诉qt构建系统在windows (7)机器上选择正确的opengl驱动程序。显卡Nvidia GT325m

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-11-13 21:53:41

对于Qt 5,它不会以常规的方式为您工作。问题是,预编译的Qt (您可能从他们的网站获得)使用GLE2.0后端默认启用GL呈现。这意味着,您的glew头将得到与qopenglfunction头中类似声明相关的所有错误。不幸的是,您将不得不使用opengl -desktop命令重新构建Qt源,该命令将消除ES2.0对you.Another的依赖,方法是使用QT4.8版本。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19963131

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档