我正在尝试组合一个非常基本的 OpenGL 3.2(核心配置文件)应用程序。在下面的代码中,应该创建一个包含三角形顶点位置的 VBO,调用glVertexAttribPointer
失败并引发 OpenGL 错误GL_INVALID_OPERATION
。这是什么意思,我该如何解决?
GLuint vbo, attribLocation = glGetAttribLocation(...);
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
GLfloat vertices[] = { 0, 1, 0, 1, 0, 0, -1, 0, 0 };
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glEnableVertexAttribArray(attribLocation);
// At this point, glGetError() returns GL_NO_ERROR.
glVertexAttribPointer(attribLocation, 3, GL_FLOAT, GL_FALSE, 0, 0);
// At this point, glGetError() returns GL_INVALID_OPERATION.