【发布时间】:2012-12-31 12:27:40
【问题描述】:
我在装有 iOS 5.1 的 iPhone 3GS 上开发了一个 OpenGL ES 2.0 程序。它使用glDrawElements OpenGL 函数。
在 iPhone 3GS 中,此代码成功返回。但是在带有 iOS 6.0.2 的 iPhone 5 中,抛出 EXEC_BAD_ACCESS。
我不知道为什么。我用索引调用 glDrawElements。小规模网格数据在 iPhone 3gs 和 iPhone 5 中都得到了很好的处理。但大规模网格数据在 iPhone 5 中是失败的。
EXEC_BAD_ACCESS 在“gleRunVertexSubmitARM”中抛出
告诉我提示。
下面是代码。 帮帮我。
glEnable(GL_DEPTH_TEST);
glEnableVertexAttribArray(_positionSlot);
glVertexAttribPointer(_positionSlot, 3, GL_FLOAT, GL_FALSE ,0, (void*)&mesh2->vertices[0][0]); // ES 2.0
glEnableVertexAttribArray(_normalSlot);
glVertexAttribPointer(_normalSlot, 3, GL_FLOAT, GL_FALSE ,0, (void*)&mesh->normals[0][0]); // ES 2.0
glDrawElements(GL_TRIANGLES, mesh2->faces.size()*3,GL_UNSIGNED_SHORT, &mesh2->faces[0].indices[0]); // <= Crash in iPhone5.
【问题讨论】:
-
_positionSlot 和 _normalSlot 与着色器的插槽链接。 _positionSlot = glGetAttribLocation(程序,“a_position”); _normalSlot = glGetAttribLocation(program,"a_normal");
-
为什么法线来自其他网格,然后是顶点和面?
-
我已经用mesh2中的原始法线数据重建了新的法线,并将其保存到网格中。这段代码在 iPhone 3GS 中运行良好,但在 iPhone 5 中却没有。
标签: iphone opengl-es ios6 crash exc-bad-access