【问题标题】:In iOS 5 with iPhone 3gs, glDrawElements success. But In iOS 6 with iPhone 5, it throw crash在 iOS 5 和 iPhone 3gs 中,glDrawElements 成功。但是在带有 iPhone 5 的 iOS 6 中,它会引发崩溃
【发布时间】: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


【解决方案1】:

我已经解决了这个问题。有问题的代码是完美的。我发现 glDisableVertexAttribArray 在其他源代码中的 glEnableVertexAttribArray 之后没有成对调用。我修好了,运行良好。 谢谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多