使用 VBO 时的 EXC_BAD_ACCESS
我没有使用 VBO 进行了一些渲染。现在我想添加 VBO 以进行更复杂的渲染。我现在只是创建一个 VBO,保留旧的渲染,现在我不使用 VBO 渲染任何内容。这是代码:
GLuint bufId;
glGenBuffers(1, &bufId);
glBindBuffer(type, bufId);
glBufferData(type, size, 0, GL_STATIC_DRAW);
//size = 100000;
这是关于 VBO 的唯一代码。但如果最后一笔没有注释,那么我在绘制GL_TRIANGLE_STRIP
时会在旧渲染中得到EXC_BAD_ACCESS。我已将 glGetError()
放在此错误访问之前,它返回 0。问题是什么?谢谢
I've made some rendering with out using VBO. Now i want to add VBO for more complex rendering. I'm just creating a VBO now, keeping the old rendering as it was and i render nothing with VBO now. Here is the code:
GLuint bufId;
glGenBuffers(1, &bufId);
glBindBuffer(type, bufId);
glBufferData(type, size, 0, GL_STATIC_DRAW);
//size = 100000;
That's the only code about VBO. But if the last stroke is not commented then i get EXC_BAD_ACCESS in old rendering when drawing GL_TRIANGLE_STRIP
. I've put glGetError()
before this bad access and it returns 0. What is the problem? thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
EXC_BAD_ACCESS 意味着您尝试读取或写入尚未映射到您的进程的内存。
发生这种情况的方式有很多种,但 glGetError() 不可能知道这一点。
我写了这篇博客,试图帮助您调试它。它适用于 iPhone,但其中的所有内容也适用于 Mac 应用程序。
http://loufranco.com/blog/files/Understanding-EXC_BAD_ACCESS.html
关键点是 EXC_BAD_ACCESS 不一定发生在错误发生时——导致它的错误可能已经运行,并且错误的访问正在响应中发生——崩溃点可能根本不相关。我的博客通过一些调试技术来找出问题的真正所在。例如,它可能与 GL 无关。
在您的代码中,
size
和type
的值是多少?可能与此无关。在到目前为止运行的所有代码中需要检查一些事情。
EXC_BAD_ACCESS means that you have tried to read or write to memory that hasn't been mapped to your process.
There are lots of ways this can happen, and there's no way that glGetError() will know about it.
I wrote this blog that tries to help you debug it. It was for iPhone, but everything in it applies to Mac apps as well.
http://loufranco.com/blog/files/Understanding-EXC_BAD_ACCESS.html
A key point is that EXC_BAD_ACCESS doesn't have to happen at the point of the bug -- the bug that caused it could have already run, and the bad access is happening in response -- the crash point may not be related at all. My blog goes through some debugging techniques to figure out where the problem really is. For example, it might have nothing to do with GL.
In your code, what is the value of
size
andtype
? It might have nothing to do with this.Some things to check for in all code that has run up to this point.
我已经找到问题了。如果你想不使用VBO来绘图,你必须解绑VBO:
之后一切正常
I've found the problem. You have to unbind VBO if you want to draw with out it:
after that everything worked