iphone - 在 iOS 5 和 iPhone 3gs 中,glDrawElements 成功。但是在 iPhone 5 的 iOS 6 中,它会崩溃

标签 iphone opengl-es ios6 crash exc-bad-access

我在装有 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.

最佳答案

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

关于iphone - 在 iOS 5 和 iPhone 3gs 中,glDrawElements 成功。但是在 iPhone 5 的 iOS 6 中,它会崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14101607/

相关文章:

javascript - 检测 iPhone IPad 等是否不工作

iphone - 如何通过我的iPhone应用程序解决声音问题

c++ - 许多立方体对象的 OpenGL 绘图元素

ios - UICollectionView 快速滚动错误行为

ios - 处理基于 NSMetadataQueryDidUpdateNotification 非 UIDocument 的 iCloud 文件时出现问题

iphone - 移除行为异常的 objectAtIndex

android - 在 phonegap ios 应用程序中显示我的索引文件 url 的地理位置确认框

android - 从分屏到全屏后出现幻影

c++ - OpenGL ES 是否适合执行骨骼动画?

ios - 分段控制 : titleForSegmentAtIndex returns null every time