gpt4 book ai didi

cocoa - glEnableVertexAttribArray 给出无效操作

转载 作者:行者123 更新时间:2023-12-03 16:25:51 25 4
gpt4 key购买 nike

我正在尝试浏览 OS X 上的 ArcSynthesis 教程,但在调用 glEnableVertexAttribArray 后收到 OpenGL 错误“无效操作”。根据 glEnableClientState and glEnableVertexAttribArray 中的讨论,我已经检查过我确实有 VBO 绑定(bind)。 ,并且不确定下一步要检查什么。

我使用的是 OS X 10.8、OpenGL 3.2 配置文件和 Xcode 4.6。

我正在尝试编写一个类,该类将加载教程中使用的 XML 模型文件,并且我认为我正在按照与早期程序相同的顺序执行相同的操作绘制一个编码模型。但我一定在某种程度上做了一些不同的或错误的事情,但不知道是什么。引用 OpenGL 3.2 文档说,通过发送超过 OpenGL 实现允许的最大值的索引值,您会得到无效的操作,但我使用的是 0 和 1,我之前使用过。

这是代码,为了清晰起见,所有 OpenGL 错误检查都被编辑掉了:

    glBindBuffer(GL_ARRAY_BUFFER, vertexBufferObject);
for (int iAttribLoop = 0; iAttribLoop < [attributeAnalyzers count]; iAttribLoop++) {
AttributeAnalyzer *theAnalyzer = [attributeAnalyzers objectAtIndex:iAttribLoop];
GLuint theIndex = [theAnalyzer index];
NSLog(@"theIndex is %d", theIndex);
glEnableVertexAttribArray(theIndex);
glVertexAttribPointer(theIndex, [theAnalyzer size], theType, GL_FALSE, 0, dataOffset);
dataOffset += sizeof(theType)*[theAnalyzer size]*[theAnalyzer vertexCount];
}

最佳答案

Referring to the OpenGL 3.2 documentation says that you get an invalid operation by sending in an index value over the maximum allowed by the OpenGL implementation

不,没有。这样做会得到 GL_INVALID_VALUEGL_INVALID_OPERATION 仅由 glEnableVertexAttribArray 给出 when you call it and no VAO is bound .

所以你应该这样做。

关于cocoa - glEnableVertexAttribArray 给出无效操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15102206/

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