OpenGL 改变方向导致 iPad 重新启动

发布于 2024-11-09 16:46:19 字数 1291 浏览 3 评论 0原文

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

剧终人散尽 2024-11-16 16:46:19

我通过销毁然后在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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文