OpenGL 改变方向导致 iPad 重新启动
我的 iPad 应用程序中存在 openGL 和方向问题。该问题仅发生在 4.3+ 设备上。 4.2 设备不会出现这种情况。
当我以任何方向启动应用程序并绘制时,它都会正确绘制,但是当我更改方向并尝试绘制时,iPad 会自行重新启动。重新启动发生在通话中
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
这是我在layoutSubviews中使用的代码:
-(void) layoutSubviews {
[EAGLContext setCurrentContext:context];
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id<EAGLDrawable>) [self layer]];
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
glScissor(0, 0, [self bounds].size.width, [self bounds].size.height);
NSLog(@"%f - %f", [self bounds].size.width, [self bounds].size.height);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);
[self erase];
[self drawExisting];
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
}
我的问题是,4.3有什么变化吗?我找不到任何说明这一点的内容。或者,如果您发现我的代码有任何问题,请告诉我。
I have a problem with openGL and orientation in my iPad app. The problem only happens with 4.3+ devices. It doesn't happen with 4.2 devices.
When I start the application with any orientation and draw, it draws correctly, but when I change the orientation, and try to draw, the iPad restarts itself. The restart happens on the call
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
This is the code I use in layoutSubviews:
-(void) layoutSubviews {
[EAGLContext setCurrentContext:context];
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id<EAGLDrawable>) [self layer]];
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
glScissor(0, 0, [self bounds].size.width, [self bounds].size.height);
NSLog(@"%f - %f", [self bounds].size.width, [self bounds].size.height);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);
[self erase];
[self drawExisting];
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
}
My question is, did anything change is 4.3? I cant find anything that states that. Or if you see anything wrong in my code, please let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过销毁然后在layoutSubviews中创建缓冲区解决了这个问题。这导致了一些我能够修复的新小问题。 destroy 和 create 方法来自这里:
http://box2d.googlecode.com /.../Box2DView.mm
I solved this problem by destroying and then creating the buffer in layoutSubviews. This caused some new minor issues that I was able to fix. The destroy and create methods are from here:
http://box2d.googlecode.com/.../Box2DView.mm