在 qopenglfunctions.h 中找不到 glGenBuffers、glBindBuffer 等
Can't find glGenBuffers,glBindBuffer etc. in qopenglfunctions.h
我正在尝试在qt 5.1.1中编写一个地图应用程序,并使用着色器使用opengl渲染。我能够使用 Glew 显示顶点。但我想使用 qopenglfunctions.h 中提供的函数奇怪的是,即使我包含这个文件,我也得到glGenBuffers没有在这个范围内声明。当我打开qopenglfunctions.h时,它就坐在那个文件中!有人遇到这个奇怪的问题吗?代码相当长。但是我添加了一些抛出链接器错误的。
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驱动程序。显卡英伟达GT325m
使用Qt 5,它不会以常规方式为您工作。问题是预编译的Qt SDK(您可能从他们的网站上获得)使用GLES 2.0后端进行默认启用的GL渲染。这意味着,你的 glew 标头将收到与 qopenglfunction 标头中的类似声明相关的各种错误。不幸的是,您将不得不使用 opengl -desktop 命令重建 Qt 源代码,这将为您消除对 ES2.0 的依赖。另一种方法是使用Qt 4.8版本。
相关文章:
- Visual Studio 19-17 库兼容性根据 GL 标志
- glDrawElements GL 错误类型 = 0x824c,严重性 = 0x9146,消息 = GL_INVALID
- 将"Compass"与相机旋转隔离开GL
- 是否有一个版本的glCopyImageSubData在Openg GL中使用混合?
- 计算着色器Open GL ES的多个输入
- Open GL ES 3.1 的计算着色器的最小工作示例
- 致命错误 C1083:无法打开包含文件:"GL/glew.h":没有此类文件或目录
- C++ 致命错误:glad/gl.h:没有这样的文件或目录
- 打开 gl 精灵类不起作用
- Qt 找不到 GL 库
- GCC 相当于 MSVC 中的 /GS、/GL、/Gy、/Oi、/MD
- 失败的 glewInit:缺少 GL 版本
- 何时在OS X上使用OpenGL vs GL
- 为什么必须同时使用 glBindBuffer 和 glBindBufferRange 在 OpenGL 中创建统一的缓冲
- 识别安卓中意外的 GL 上下文丢失
- Android Native:CMake 链接错误:未定义对 GL 函数的引用 - 即使包含并链接了 EGL 和 GLESv3
- Glew - 与 GLFW 配对时 gl- 函数符号上出现链接错误
- 如果我们有glBindBuffer,"glGenBuffers"真的很重要吗?
- 打开gl es 2.0为什么我的VBO不起作用
- iOS GL ES exc_bad_access on glDrawElements