OpenGL:glVertexAttribPointer()失败,“无效值”在新的NVIDIA驱动程序上大于2048的步幅

时间:2013-12-13 10:41:45

标签: opengl driver nvidia

是否还有其他人认识到使用新的NVIDIA驱动程序(从331.58 WHQL及更高版本)调用glVertexAttribPointer()以及大于2048的步幅是不可能的?该调用会创建OpenGL错误无效值(1281)

例如,在使用驱动程序331.58 WHQL后调用testStride(2049);后,以下最小GLUT示例将生成OpenGL错误 1281

#include <iostream>
#include <GL/glut.h>
#include <windows.h>

using namespace std;

PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = 0;

void testStride(const GLsizei stride)
{
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, stride, 0);
    GLenum code = glGetError();
    if (code != GL_NO_ERROR)
         std::cerr << "glVertexAttribPointer() with a stride of " << stride << " failed with code " << code << std::endl;
    else std::cout << "glVertexAttribPointer() with a stride of " << stride << " succeeded" << std::endl;
}

void render(void)
{
    testStride(2048); // Works well with driver version 311.06 and 331.58
    testStride(2049); // Does not work with driver version 331.58 but works well with driver version 311.06
}

int main(int argc, char* argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
    glutCreateWindow("Window");
    glutDisplayFunc(render);

    glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) wglGetProcAddress("glVertexAttribPointer");

    glutMainLoop();
    return 0;
}
你有什么看法?我做错了吗?

@Christian Rau:非常感谢您的提示。我立即用glVertexAttribPointer()替换glVertexPointer()调用,但仍得到相同的结果。

1 个答案:

答案 0 :(得分:1)

OpenGL 4.4添加了GL_MAX_VERTEX_ATTRIB_STRIDE,这正是它听起来的样子:对你允许使用的最大步幅的一个严格的,实现定义的限制。它同样适用于separate attribute formats和旧式glVertexAttribPointer