iPhone/iPad、OpenGL ES、CADisplayLink

发布于 2024-10-11 09:53:57 字数 1001 浏览 1 评论 0原文

我刚刚开始使用 OpenGL ES,主要是在 iPad 上,并注意到一些我无法找到答案的问题。首先,我尝试在同一窗口中使用两个使用单独渲染器的 EAGLView。基本上认为 XCode 中的 OpenGL ES 示例项目有两个 EAGLView 和两个渲染器等。现在这似乎在模拟器中不起作用,它只显示其中一个视图(似乎运行渲染代码,但只有一个视图是使用 openGL 显示),但是当在设备(使用 iOS 4.2 的 iPad)上运行时,它确实可以工作,至少在某种程度上这会导致下一个问题。

渲染的更新是在这两个视图上使用 CADisplayLink 触发的。然而,这确实会导致一些问题。大多数情况下,不久之后,其中一个视图的更新就会停止,其 CADisplayLink 就会停止触发。这仅发生在设备上,而不发生在模拟器中。它可以通过使用计时器而不是 CADisplayLink 来“修复”,或者在一个视图上使用计时器而在另一个视图上使用 DisplayLink,但我想知道是什么原因造成的。我正在创建这样的显示链接(在两个视图中):

self.displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self 选择器:@selector(drawView:)];

[displayLink setFrameInterval:animationFrameInterval];

[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];

现在最后一个问题是关于我注意到的一件奇怪的事情。当在 iPad 模拟器中运行 Xcode 中提供的 OpenGL ES 示例项目并将视图调整为宽度低于 760 时,它不会在屏幕上渲染任何内容,它只涉及宽度,但高度可以以任何方式调整大小。它只发生在模拟器中,而不发生在设备上。

所以问题基本上是上面提到的事情是否是错误、功能或者我只是做错了?

谢谢 /j0h

I've just started playing with OpenGL ES, mostly on iPad and have noticed some problems I cannot find the answer to. First I've tried using two EAGLViews using separate renderers in the same window. Basically think the OpenGL ES example project in XCode but with two EAGLViews and two renderers etc. Now this does not seem to work in the simulator, it only shows one of the views (it seems to run the rendering code, but only one view is displayed with openGL) but when run on the device (an iPad using iOS 4.2) it does work, at least kind of which leads to the next question.

The updates to the rendering is triggered using CADisplayLink on both these views. This does however cause some problems. Most of the time, after just a short while, the updates on one of the views stops, its CADisplayLink stops triggering. This only happens on the device and not in simulator. It can be "fixed" by using timers instead of CADisplayLink, or timer on one view and DisplayLink on the other, I would like to know what is causing this though. I'm creating the display link like this (in both views):


self.displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(drawView:)];

[displayLink setFrameInterval:animationFrameInterval];

[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];

Now the last question is about an odd thing I have noticed. When running the OpenGL ES example project provided in Xcode in the iPad simulator with the view resized below 760 in width, it does not render anything to screen, It only concerns the width though, the height can be resized in any way. It only happens in the simulator, not on the device.

So the questions are basically if the things mentioned above are bugs, features or if I'm just doing it wrong?

Thanks
/j0h

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

清君侧 2024-10-18 09:53:57

我发现同时运行两个 OpenGL 视图有类似的问题,每个视图都运行在单独的 CADisplayLink 上,都运行 forMode: NSDefaultRunLoopMode。在运行 iOS 5.1 的 iPhone 4S 上进行测试时,除了退出 MPMediaPickerController 时其中一个视图将停止渲染之外,没有任何问题。然而,在运行 iOS 5.0.1 的 iPod Touch 3rd gen 上,我确实注意到一个或另一个视图会随机停止渲染的问题(由于 CADisplayLink 未触发)。我可以通过切换到 NSTimer 来修复它(仅对其中一个或另一个视图执行此操作是行不通的)。大小为 32 的倍数对我来说没有任何区别。

I found a similar problem running two OpenGL views at once, each running on a separate CADisplayLink, both running forMode: NSDefaultRunLoopMode. When testing on an iPhone 4S running iOS 5.1, there were no issues except for when exiting the MPMediaPickerController, one of the views would stop rendering. However, on the iPod Touch 3rd gen running iOS 5.0.1, I did notice the issue where one or the other view would stop rendering randomly (due to CADisplayLink not firing). I was able to fix it by switching to NSTimer for both views (just doing it for one or the other wouldn't work). Sizing to multiples of 32 did not make any difference for me.

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